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];
        var sort = new List<long>();
        for (int i = 0; i < n; i++)
        {
            a[i] = long.Parse(Console.ReadLine());
            
            if (!sort.Contains(a[i]))
            {
                sort.Add(a[i]);
            }
        }

        sort.Sort();

        long ans = 0;
        
        for (int i = 0; i < n; i++)
        {
            if (a[i] != sort[sort.Count-1])
            {
                Console.WriteLine(sort[sort.Count-1]);
            }
            else if (sort.Count == 1)
            {
               Console.WriteLine(a[i]);
            }
            else
            {
                Console.WriteLine(sort[sort.Count-2]);
            }
        }
    }
}
