n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
ma=a[0]
b=a[0]
for j in range(1,n):
    if(ma<a[j]):
        ma=a[j]
for l in range(n):
    if(a[l]!=ma):
        print(str(ma))
    else:
        for j in range(1,n):
            if(j!=l and ma<a[j]):
                ma=a[j]
        print(str(ma))
