n=int(input())
a=[]
for i in range(n):
	a.append(int(input()))
ma=max(a)
keiken=0
b=[]
for i in range(n):
	if a[i]==ma and keiken==0:
		for ii in range(n):
			if ii!=i:
				b.append(a[ii])
		print(max(b))
	else:
		print(ma)
