n=int(input())
a=list(int(input()) for i in range(n))
if a.count(max(a))==1:
  for y in range(n):
  	if a[y]==max(a):
  		a.remove(a[y])
  		print(max(a))
  	else:
  		print(max(a))
else:
  for i in range(n):
    print(max(a))

