n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
c=max(a)
check=False
for i in range(n):
    if a[i]==c&&check==False:
        b=a[:i]+a[i+1:]
        d=max(b)
        print(d)
    elif a[i]==c&&check==True:
        print(d)
    else:
        print(c)