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

for i in range(N):
    if i == 0:
        print(max(A[1:]))
    elif i == N-1:
        print(max(A[:N-1]))
    else:
        l = max(A[:i])
        r = max(A[i+1:])
        print(max(l,r))