N = int(input())
A = [int(input()) for i in range(N)]
for i in range(N):
    A_new1 = A[:i] + [0]
    A_new2 = A[i+1:] + [0]
    if max(A_new1) >= max(A_new2):
        print(max(A_new1))
    else:
        print(max(A_new2))
