N = int(input())
A = [int(input()) for _ in range(N)]
A_max = max(A)
for i in range(N):
    if A[0] != max(A):
        print(max(A))
    else:
        B = A.copy()
        del B[i]
        print(max(B))