n = int(input())
a = [int(input()) for _ in range(n)]
l, r = [1] * n, [1] * n
for i in range(1, n):
	l[i] = max(l[i], a[i - 1])
for i in range(n - 2, -1, -1):
	r[i] = max(r[i], a[i + 1])
for i in range(n):
	print(max(l[i], r[i]))