n = int(input())
a = [int(input()) for i in range(n)]
m = max(a)
for j in range(n):
	if a[j] < m:
		print(m)
	elif a[j] == m:
		if a.count(m) > 1:
			print(m)
		else:
			b = a[:]
			b[j] = 0
			print(max(b))
	else:
		b = a[:]
		b[j] = 0
		print(max(b))