package polica;

import java.util.Scanner;

/**
 *
 * @author Nemanja
 */
public class Polica {

    public static void main(String[] args) {
        final int MAX_BROJ_KNJIGA = 1000000;
        int[] A = new int[MAX_BROJ_KNJIGA];
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        for (int i = 0; i <= N - 1; i++) {
            A[i] = input.nextInt();
        }
        if (A[0] < A[1]) {
            int t = A[0];
            A[0] = A[1];
            A[1] = t;
        }
        for (int i = 1; i <= N - 1; i++) {
            if (A[i] >= A[i - 1]) {
                int t = A[i];
                A[i] = A[i - 1];
                A[i - 1] = t;
                break;
            }
        }

        for (int i = 0; i <= N - 1; i++) {
            System.out.print(A[i] + " ");
        }

    }

}