import copy

N = int(input())

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


_max = max(A)

for i in range(N):
    if A[i] == _max:
        _A = copy.deepcopy(A)
        del _A[i]
        print(max(_A))

    else:
        print(_max)
        