N = int(input())
A = [int(input()) for i in range(N)]
for i in range(N):
    if i!=0 and i!= N-1:
        ans = max(max(A[:i]),max(A[i+1:]))
    elif i == 0:
        ans = max(A[i+1:])
    else:
        ans = max(A[:i])
    print(ans)
