if __name__ == "__main__":
  inNum = int(input())
  intArr = []


  while(inNum > 0):
      tempNum =int(input())
      intArr.append(tempNum)
      inNum = inNum-1

  intArr
  sortArr = intArr
  sortArr.sort()
  for x in intArr:
      if(not x == sortArr[-1]):
          print(sortArr[-1])
      if(x == sortArr[-1]):
          print(sortArr[-2])