N = int(input())

A = [0] * N
for i in range(N):
    a = int(input())
    A[i] = a

for i in range(N):
    tmp = A[:]
    ans = max(tmp)
    if ans == A[i]:
        ans = sorted(tmp)[-2]
    print(ans)   