t=int(input())
l=[]
b=0
c=0
for j in range(t):
    a=int(input())
    l.append(a)
    if(a>b):
        b=a
    elif(b>a):
        c=a
for i in l:
    if(i!=b):
        print(b)
    else:
        print(c)
