n = int(input())
A = [int(input()) for i in range(n)]
l = 0
L = [l]
for a in A:
    L.append(max(l, a))
r = 0
R = [r]
for a in A[::-1]:
    R.append(max(r, a))
R.reverse()
for i in range(n):
    print(max(L[i], R[i+1]))
