n = int(input())
l=[int(input()) for x in range(n)]
setl=list(set(l))
m=max(l)

for i in range(n):
    if len(setl)==1:
        print(m)
    else:
        second=setl[-2]
        if l[i]==m:
            print(second)
        else:
            print(m)