n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))

maxmax=max(a)

for i in range(n):
    if a[i]!=maxmax:
        print(maxmax)
    elif a[i]==maxmax:
        temp=a[i]
        a[i]=0
        print(max(a))
        a[i]=temp