N = int(input())
numbers_full = [int(input()) for _ in range(N)]

numbers_minus1 = numbers_full
for i, tmp in enumerate(numbers_full):
  numbers_minus1[i] = 0
  print(str(max(numbers_minus1)))
  numbers_minus1[i] = tmp