using System;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');
            int[] arr = a.Select(x => int.Parse(x)).ToArray();
            int i = 0;
            while (true)
            {
                if (i > arr.Length - 1)
                    break;
                int index = find(arr, i);
                if(arr[i] < arr[index])
                {
                    int pom = arr[i];
                    arr[i] = arr[index];
                    arr[index] = pom;
                    break;
                }
                i++;
            }
            for(int j = 0; j < arr.Length; j++)
            {
                Console.Write(arr[j]);
                Console.Write(' ');
            }
        }
        static int find(int[] arr, int start)
        {
            int max = 0;
            int index = 0;
            for(int i = start; i < arr.Length; i++)
            {
                if(arr[i] >= max)
                {
                    max = arr[i];
                    index = i;
                }
            }
            return index;
        }
    }
}