N = int(input())
A = [int(input()) for i in range(N)]

B = sorted(A)
for i in range(N):
    if A[i] != B[N-1]:
        print(B[N-1])
    else:
        for j in range(N):
            if A[i] != B[(N-1)-j]:
                print(B[N-1-j])
                break