import copy

N = int(input())

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

for i in range(N):
    remain = set(A) - set([A[i]])

    if remain == set():
        print(A[i])
    else:
        print(max(remain))