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

namespace POLICA
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong n = ulong.Parse(Console.ReadLine());
            int max = 0;
            int[] a = new int[n];
            int[] b = new int[n];
            string[] s = Console.ReadLine().Split();
            for (ulong i = 0; i < n; i++)
            {
                a[i] = int.Parse(s[i]);
                b[i] = a[i];
                max = Math.Max(max, a[i]);
            }
            int x;
            if (n == 2)
            {
                x = a[0];
                a[0] = a[1];
                a[1] = x;
            }
            else
            {
                for (ulong i = 0; i < n; i++)
                {
                    if (a[i] != b[i])
                        for (ulong j = n - 1; j >= i + 1; j--) 
                        {
                            if (a[j] == b[i])
                            {
                                x = a[i];
                                a[i] = a[j];
                                a[j] = x;
                            }
                            break;
                        }
                    else if(i==n-1)
                    {
                        x = a[i];
                        a[i] = a[i - 1];
                        a[i - 1] = x;
                    }
                }
            }
            for (ulong i = 0; i < n; i++)
            {
                Console.Write(a[i] + " ");
            }
        }
    }
}