n=int(input())
a=list()
for i in range (n):
    a.append(int(input()))
new_a_reverse=sorted(a,reverse=True)
for i in range(n):
    if(max(a)==a[i]):
        print(new_a_reverse[1])
    elif(max(a)!=a[i]):
        print(max(a))
