# C - Exception Handling
N = int(input())
A = [int(input()) for i in range(N)]

#print(A)
max1 = max(A)

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