using System;

namespace TakProg2
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            string c = Console.ReadLine();
            string[] a = c.Split();
            int[] niz1 = new int[N];
            for (int i = 0; i < a.Length; i++)
            {
                niz1[i] = int.Parse(a[i]);
            }
            if (N == 2)
            {
                int pom = niz1[0];
                niz1[0] = niz1[1];
                niz1[1] = pom;
            }
            if (N > 2)
            {
                for (int i = 0; i < niz1.Length-1; i++)
                {
                    if (niz1[i]<niz1[i+1])
                    {
                        int pom = niz1[i];
                        niz1[i] = niz1[i+1];
                        niz1[i+1] = pom;
                        break;
                    }
                }
            }

            for (int i = 0; i < niz1.Length; i++)
            {
                Console.Write(niz1[i]+" ");
            }
        }
    }
}