a=[]
m1,m2=0,0
ct=0
t=input()
for i in range(t):
    n=input()
    a.append(n)
    if n>m1:
        m2=m1
        m1=n
        ct=i
    elif n>m2:
        m2=n
for i in range(t):
    if i==ct:
        print m2
    else:
        print m1
