n = int(input())
l=[int(input()) for x in range(n)]
ll=sorted(set(l))
for i in range(n):
    if l[i]<max(l):
        print(max(l))
    elif l[i]==max(l):
        if len(ll)==1:
            print(ll[0])
        else:
            print(ll[-2])
