using System;

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

        for (int i = 0; i < length; i++)
        {
            var array_copy = new int[length];
            Array.Copy(array, array_copy, length);
            array_copy[i] = -1;
            Array.Sort(array_copy);
            Console.WriteLine(array_copy[length - 1]);
        }
    }
}