N = int(input())
A = [int(input()) for _ in range(N)]
for n in range(N):
    if n == 0:
        print(max(A[n + 1:]))
    elif n == N - 1:
        print(max(A[:n]))
    else:
        print(max(max(A[:n]), max(A[n + 1:])))