N = int(input())
A = []
for n in range(N):
    A.append(int(input()))

max_A = sorted(A)[-1]
second_A = sorted(A)[-2]

for n in range(N):
    if A[n] != max(A):
        print(max(A))
    else:
        print(second_A)