n = int(input())
l = []
for _ in range(n):
  l.append(int(input()))
m = max(l)
for i in range(0,n):
    if l[i] != m:
      print(m)
    else:
      l.pop(i)
      p = max(l)
      print(p)
      l.insert(i,m)