N = int(input())

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

m = max(A)
flag = 1
for n in range(N):
    if A[n] == m and flag == 1:
        print(A[n])
        flag = 0
    
    print(m)