n=int(input())
a_li=[]
for i in range(n):
    a=int(input()) 
    a_li.append(a)
for i in range(n):
    b=max(a_li)
    if b>a_li[i]:
        ans=b
    else:
        if a_li.count(b)>1:
            ans=b
        else:
            a_li.remove(b)
            ans=max(a_li)
            a_li.insert(i,b)
    print(ans)
        
        