n = int(input())
a = [int(input()) for i in range(n)]
a_set = list(set(a))
a_set.sort(reverse=True)

if len(a_set) > 1:
  for i in range(n):
    if a[i] != a_set[0]:
      print(a_set[0])
    elif a[i] == a_set[0]:
      print(a_set[1])
elif len(a_set) == 1 :
  for i in range(n):
    print(a[0])