n=int(input())
a=[]
m=0
for i in range(n):
    a.append(int(input()))
for i in range(n):
    if a[i]!=max(a):
        print(max(a))
    else:
        m=a[i]
        a[i]=1
        print(max(a))
        a[i]=m