N = int(input())
li = []
for i in range(N):
  s = int(input())
  li.append(s)
  
  new = sorted(li, reverse=True)

s = max(li)
for index, i in enumerate(li):
  if s == li[index]:
    print(new[1])
  else:
    print(new[0])