n = int(input())
numList  = [input() for i in range(n)]
maxVal = max(numList)
workList = numList[:]
secondVal = max(workList.remove(maxVal))
for num in numList:
  if num != maxVal:
    print(maxVal)
  else
    print(secondVal)