N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
    
    
import copy
U=copy.deepcopy(A)
del U[U.index(max(U))]
for i in range(N):
    if i==A.index(max(A)):
        print(max(U))
    else:
        print(max(A))