def resolve():
    N = int(input())
    A = [int(input()) for n in range(N)]
    B = A.copy()
    B.sort()
    for i in range(N):
        if max(A) > A[i]:
            print(max(A))
        elif max(A) == A[i]:
            if A.count(max(A)) >= 2:
                print(max(A))
            else:
                print(B[-2])
    return

resolve()