import java.util.Scanner;

public class Polica {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		byte[] niz = new byte[N];
		byte max = 0;
		int n = 0;
		for (int i = 0; i < N; i++) {
			niz[i] = scan.nextByte();
			if (niz[i] >= max) {
				max = niz[i];
				n = i;
			}

		}
		for (int i = 0; i < N; i++) {

		}
		int z = 0;

		for (int i = 0; i < N; i++) {
			if (niz[i] < max && i < n) {
				byte p = niz[i];
				niz[i] = niz[n];
				niz[n] = p;
				z = 1;
				break;
			}

		}

		if (z == 0) {
			while (max > 0 && z == 0) {
				max = max--;
				for (int i = 0; i < N; i++) {
					if (niz[i] >= max) {
						max = niz[i];
						n = i;
					}
					for (int j = 0; j < N; j++) {
						if (niz[j] < max && j < n) {
							byte p = niz[j];
							niz[j] = niz[n];
							niz[n] = p;
							z = 1;
							break;
						}

					}

				}
			}

		}

		for (byte b : niz) {
			System.out.print(b + " ");
		}

	}
}