n = int(input())
a = list(map(int,[input() for i in range(n)]))
a_set = set(a)

for num in a:
  if len(list(a_set))==1:
    print(max(a))
  elif num==list(a_set)[-1]:
    print(list(a_set)[-2])
  else:
    print(max(a))