n = int(input())
a = [0]*n
for i in range(n):
  a[i] = int(input())

x = sorted(a, reverse = True)
  
max = x[0]
count = x.count(max)
for i in range(n):
  if a[i] == max:
      print(max)      
  else:
    print(x[1])
  