N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
    if i == 0:
        print(max(A[1:]))
        continue
    elif i == N-1:
        print(max(A[:N]))
        continue
    
    a_l = max(A[:i])
    a_h = max(A[i+1:])
    
    if a_l >= a_h:
        print(a_l)
    else:
        print(a_h)
    