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

B = []
for i in range(N):
    B = A[:]
    bi = B.pop(i)
    if bi == amax:
        B.sort()
        print(B.pop())
    else:
        print(amax)
