N = int(input())
A = []

for i in range(N):
    A.append(int(input()))

buff = A.copy()
buff.sort()
buff = buff[::-1]

for i in range(N):
    if A[i] == buff[0]:
        print(buff[1])
    else:
        print(buff[0])