def resolve():
    n = int(input())
    A = [int(input()) for i in range(n)]
    B = sorted(A)
    for a in A:
        if a == max(B):
            print(B[-2])
        else:
            print(max(B))
resolve()