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