using System;
class Program {
    static void Main() {
        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        string[] a = s.Split(null);
        int i, j, x, y;
        int max = -1;
        int index = -1;
        if (n == 2) {
            Console.Write("{0} ",a[1]);
            Console.Write(a[0]);
        }
        else {
            for (i = 0; i < n; i++) {
                x = int.Parse(a[i]);
                for(j = i+1; j < n; j++) {
                    y = int.Parse(a[j]);
                    if (y >= max) { 
                        max = y;
                        index = j;
                    }
                }
                y = max;
                if (y > x && index > i) {
                    a[i] = y.ToString();
                    a[index] = x.ToString();
                    break;
                }
            }
            foreach (string e in a) { Console.Write("{0} ",e); }
        }
    }
}