n = int(input())
a = []
for _ in range(n):
  a.append(int(input()))

maxnum = max(a)

for i in range(n):
  tmp = a.pop(i)
  if tmp == maxnum:
    print(max(a))
  else:
    print(maxnum)
  a.insert(i, tmp)
