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