N = int(input())
A = [int(input()) for i in range(N)]

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