N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
max_A = max(A)
for i in A:
    if i == max_A:
        if A.count(max_A) > 1:
            print(max_A)
        else:
            tmp = A.copy()
            sorted(tmp)
            print(tmp[-1*A.count(max_A)])
    else:
        print(max_A)