n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)

for i in range(n):
  if a[i] != ma:
    print(ma)
  elif a.count(ma) > 1:
    print(ma)
  else:
    temp = a[:]
    del temp[i]
    print(max(temp))