hako = []
zan = []
num = int(input())
for n in range(num):
  hako.append(int(input()))
for h in range(len(hako)):
  zan.append(hako[h])
  hako.remove(hako[h])
  print(max(hako))
  hako.insert(h, zan[h])