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

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            string inpt = Console.ReadLine();
            long N = long.Parse(inpt);
            char[] temp = new char[N];
            string[] tokens = Console.ReadLine().Split();
            for (int i = 0; i < N; i++)
            {
                temp[i] = tokens[i][0];
            }
            char p;
            char[] temp1 = new char[N];
            char[] tempMAX = new char[N];
            temp.CopyTo(temp1,0);
            temp.CopyTo(tempMAX, 0);
            string t1;
            string t2 = string.Join("", temp);
            if (temp.Length>2)
            {
                for (int i = 0; i < N; i++)
                {
                    for (int j = 0; j < N; j++)
                    {
                        if (i != j)
                        {
                            p = temp1[i];
                            temp1[i] = temp1[j];
                            temp1[j] = p;
                            t1 = string.Join("", temp1);
                            if ((t1.ToString().CompareTo(t2.ToString())) == 1)
                            {
                                tempMAX = temp1;
                                t2= string.Join("", tempMAX);
                            }
                            temp.CopyTo(temp1,0);
                        }
                    }
                }
            }
            else
            {
                p = temp1[0];
                temp1[0] = temp1[1];
                temp1[1] = p;
                tempMAX = temp1;
                t2 = string.Join("", tempMAX);
            }


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