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

ma = max(A)
for i in range(N):
    if A[i] == ma:
        A[i] = 0
        print(max(A))
        A[i] = ma
    else:
        print(ma)