n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
maxi = max(a)
for i in range(n):
  if a[i] == maxi:
    b = []
    b += a
    b.remove(maxi)
    print(max(b))
  else:
    print(maxi)