import numpy as np
import sys

n=int(sys.stdin.readline())
a=np.array([sys.stdin.readline() for _ in range(n)],dtype='int64')


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