def resolve():
    N = int(input())
    A = [int(input()) for i in range(N)]

    mx = max(A)
    for i in range(N):
        s = A[i]
        if mx != s:
            print(mx)
        else:
            print(sorted(A)[-2])
            
resolve()