test = int(input())
a = []



for i in range(test):
	a.append(int(input()))

b = a[:]
b.reamove(max(a))
mx = max(a)
smx = max(b)

for i in range(test):
	if a[i]==max(a):
		print(smx)
	else:
		print(mx)	
