N = int(input())
A = [int(input()) for _ in range(N)]

a_max = max(A)

for i,a in enumerate(A):
    if a == a_max:
        A[i] -= a
        print(max(A))
        A[i] += a
    else:
        print(a_max)