
n=int(input())
a=[]
b=[]
for i in range(n):
    num=int(input())
    a.append(num)
    b.append(num)
b.sort(reverse=True)
x=a.count(a[0])
for i in range(n):
    if(a[i]==b[0]):
        if(x==1):
            print(b[1])
        else:
            print(b[0])
    else:
        print(b[0])
