N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A,reverse=True)
if B[0] = B[1]:
    for i in range(N):
        print(B[0])
else:
    for i in range(N):
        if A[i] = B[0]:
            print(B[1])
        else:
            print(B[0])