N = int(input())
lst = list([int(input()) for i in range(N)])
a = max(lst)
for i in range(N):
  if lst[i] != a:
    print(a)
  else:
    copy_lst = lst.copy()
    copy_lst.remove(copy_lst[i])
    print(max(copy_lst))