N = int(input())
A = []
mx=0
for i in range(N):
    A.append(int(input()))


if A.count(max(A)) > 1:
    for i in range(N):
        print(max(A))
else:
    for i in range(N):
        if A[i] != max(A):
            print(max(A))
        else:
            print(sorted(A)[-2])