import copy

N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

max_value = max(a_list)

for i in range(N):
  if a_list.count(max_value) > 1:
    print(max_value)
  else:
    if a_list[i] == max_value:
      print(sorted(a_list)[-2])
    else:
      print(max_value)
  
