n = int(input())
lst = []
max_num = 0

for i in range(n):
    a = int(input())
    lst.append(a)
    if a > max_num:
      max_num = a
      
for i in range(n):
  if lst[i] != max_num:
    print(max_num)
  else:
    lst[i] = 0
    print(max(lst))
