N = int(input())
A = [None] * N
for i in range(N):
    A[i] = int(input())

b = max(A)

for i in range(N):
    if A[i] == b:
        a = A[i]
        A[i] = 0
        ans = max(A)
        print(ans)
        A[i] = a
    else:
        print(b)