N = int(input())
A = [int(input()) for i in range(N)]
B = list(A)
max_A = max(A)
for i in range(N):
    if max_A == A[i]:
        B.remove(A[i])
        print(max(B))
        B = list(A)
    else:
        print(max_A)