n=input()
n=int(n)
l=[]
for i in range(n):
    x=input()
    x=int(x)
    l.append(x)
ans=max(l)
for i in range(n):
    
    if l[i]==ans:
        del l[i]
        print(max(l))
        l.append(0)
        continue
    print(ans)
    
