import sys
from sys import stdin
n = int(stdin.readline().rstrip())
a = [int(stdin.readline().rstrip()) for x in range(n)]

for i in range(len(a)):
    if a[:i] == []:
        print(max(a[i+1:]))
    elif a[i+1:] == []:
        print(max(a[:i]))
    else:
        print(max(max(a[i+1:]),max(a[:i])))