using System;

public static class Program
{
    public static void Main(string[] args)
    {
        var length = int.Parse(Console.ReadLine());
        int[,] array = new int[length,2];
        for (int i = 0; i < length; i++)
        {
            array[i,0] = int.Parse(Console.ReadLine());
        }

        for (int i = 0; i < array.GetLength(0);i++)
        {
            var temp = -1;
            for (int j = 0; j < array.GetLength(0); j++)
            {
                if (i == j)
                {
                    continue;
                }

                if (temp < array[j, 0])
                {
                    temp = array[j, 0];
                    array[i, 1] = j;
                }
            }
        }

        for (int i = 0; i < array.GetLength(0); i++)
        {
            Console.WriteLine(array[array[i,1],0]);
        }
    }
}