def solve():
    for i in range(n):
        if a[i]!=a_max:
            print(a_max)
        else:
            a[i]=0
            print(max(a))
            a[i]=a_max

n=int(input())
a=[int(input()) for i in range(n)]
a_max=max(a)
solve()