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

namespace _2.polica
{
    class Program
    {

        public static List<int> crna = new List<int>();

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string[] b = Console.ReadLine().Split();
            int[] a = new int[b.Length];
            for (int i = 0; i < b.Length; i++) a[i] = Convert.ToInt32(b[i]);

            int k = 0;

            if (a.Length == 2)
            {
                Console.WriteLine(a[1] + " " + a[0]);
            }
            else
            {
                while (true)
                {
                    int index = maksimum(ref a);
                    for (int i = 0; i < index; i++)
                    {
                        if (a[index] > a[i])
                        {
                            int temp;
                            temp = a[index];
                            a[index] = a[i];
                            a[i] = temp;
                            k = 1;
                            break;
                        }
                    }
                    if (k == 1) break;
                }
                foreach (int x in a) Console.Write(x + " ");
            }
        }

        static public int maksimum(ref int[] a)
        {
            int max = -1;
            int index = -1;
            for (int i = a.Length - 1; i >= 0; i--)
            {
                if (a[i] > max && !crna.Contains(a[i]))
                {
                    max = a[i];
                    index = i;
                }
            }
            crna.Add(max);

            return index;
        }
    }
}