n=int(input())
a=[int(input()) for i in range(n)]
adic={}
for i in range(n):
    adic[i]=a[i]

temp=sorted(adic.items(),key=lambda x: x[1],reverse=True)
for i in range(n):
    if i != temp[0][0]:
        print(max(a))
    else:
        print(temp[1][1])
