import copy
n = int(input())
a = [int(input()) for i in range(n)]
pre_max = max(a)

for i in range(n):
  if pre_max != a[i]:
    print(pre_max)
  else:
    copy_a = copy.copy(a)
    copy_a.pop(i)
    print(max(copy_a))
  