N = int(input())
mylist = []
for i in range (N):
  A = int(input())
  mylist.append(int(A))
for j in range (N):
  data = mylist[j]
  my = sorted(mylist,reverse=True)
  if data == my[0]:
    print(my[1])
  else:
    print(my[0])