n = int(input())
xlist = [int(input()) for i in range(n)]
a = max(xlist)
for i in range(n):
  if xlist[i] != a:
    print(a)
  else:
    b = xlist[i]
    xlist.pop(i)
    print(max(xlist))
    xlist.insert(i,b)