n = int(input())
numList = []
for i in range(n):
  numList.append(int(input()))

workList = numList[:]
for j in range(n):
  workList.remove(numList[j])
  print(max(set(workList)))
  workList = numList.copy()