using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace police
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            var s1 = Console.ReadLine().Split(' ');
            for (var i = 0; i < n; i++)
            {
                a[i] = int.Parse(s1[i]);
            }
            if (n == 2)
            {
                int p = a[0];
                a[0] = a[1];
                a[1] = p;


            }

            else
            {
                int max = a[0]; short br = 0; int maxid = 0;
                for (int i1 = 0; i1 < n && br == 0; i1++)
                {
                    for (int i = 1; i < n; i++)
                    {
                        if (max < a[i])
                        {
                            max = a[i];
                            maxid = i;
                        }
                    }
                    if (a[0] != max)
                    {
                        int p = a[i1];
                        a[i1] = a[maxid];
                        a[maxid] = p;
                        br++;
                    }
                }

            }
            for (int i = 0; i < n - 1; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.Write(a[n - 1]);
            Console.WriteLine(" ");
        }
    }
}