using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {

            string input = Console.ReadLine();
            int N = int.Parse(input);
            int[] ary = new int[N];


            ary[0] = int.Parse(Console.ReadLine());
            ary[1] = int.Parse(Console.ReadLine());

            int max1 = ary[0] < ary[1] ? ary[1] : ary[0];
            int max2 = ary[0] < ary[1] ? ary[0] : ary[1];

            for (int i = 2; i < N; i ++ )
            {
                input = Console.ReadLine();
                ary[i] = int.Parse(input);

                if(max1 <= ary[i] ) {
                    max2 = max1;
                    max1 = ary[i];
                }
            }


            for(int i = 0; i < N; i++ )
            {
                if (max1 == max2)
                {
                    Console.WriteLine(max1);
                }
                else
                {
                    if(ary[i] != max1)
                    {
                        Console.WriteLine(max1);
                    } else
                    {
                        Console.WriteLine(max2);
                    }
                }
            }


            return;
        }



    }
}
