from copy import deepcopy

def solve():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    B = deepcopy(A)
    B.sort()

    for a in A:
        if a != B[-1]:
            print(B[-1])
        else:
            print(B[-2])

print(solve())