n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
m=max(a)
ind=a.index(m)
m2=a[0]
for i in range(n):
    if i!=ind:
        m2=max(m2,a[i])
for i in range(n):
    if i==ind:
        print(m2)
    else:
        print(m)