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