
namespace ABC134Prac.C
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;

    public class Program
    {

        public static void Main(string[] args)
        {
            var n = ReadInputAsInt();
            var A = ReadLinesAsInt(n).ToList();


            foreach (var max_i in Solve(n, A))
            {
                WriteLine(max_i);
            }
        }

        public static IEnumerable<int> Solve(int n, List<int> a)
        {

            for (int i = 0; i < n; i++)
            {
                var _a = new List<int>(a);
                _a.RemoveAt(i);
                yield return _a.Max();
            }

        }

        static int ReadInputAsInt() => int.Parse(ReadLine());

        static IEnumerable<int> ReadLinesAsInt(int n)
        {
            for (int i = 0; i < n; i++)
            {
                yield return int.Parse(ReadLine());
            }
        }
    }
}
