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];
        

        for (int i = 0; i < n; i++)
        {
            a[i] = long.Parse(Console.ReadLine());
        }

        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            IEnumerable<long> count = a.Where( value => value!=a[i] );
            if (count.Count() > 0)
            {
                Console.WriteLine(count.Max());
            }
            else
            {
                Console.WriteLine(a[i]);
            }
        }
    }
}
