n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
a_max = max(a)
a_copy = a[:]
while a_max in a_copy:
	a_copy.remove(a_max)
if a_copy:
	for i in range(n):
		print(a_max if a[i] != a_max else max(a_copy))
else:
	for i in range(n):
		print(a_max)