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

maximum = max(A)
for i in range(N):
    if A[i] == maximum:
        new = A[:]
        new.pop(i)
        print(max(new))
    else:
        print(maximum)