n = int(input())
a = [0 for i in range(n)]
for i in range(n):
    a[i] = int(input())

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