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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        long[] a = new long[n];
        long[] sort = new long[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = long.Parse(Console.ReadLine());
            
            if (!sort.Contains(a[i]))
            {
                sort[i] = a[i];
            }
        }

        Array.Sort(sort);

        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (Array.IndexOf(sort, a[i]) > 0)
            {
                Console.WriteLine(a[i-1]);
            }
            else
            {
                Console.WriteLine(a[i]);
            }
        }
    }
}
