N=int(input())

import numpy as np
seq=np.array([])

for i in range(N):

    a= int(input())
    
    seq=np.append(seq,a)

index=np.argsort(seq)[::-1]
for j in range(N):
    if index[0]==j:
        print(int(seq[index[1]]))
    else:
        print(int(seq[index[0]]))
