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

def max_pick(list,i):
  list.pop(i-1)
  z=list[0]
  for j in range(1,N-1):
    if z<list[j]:
      z=list[j]
  return z

for i in range(1,N+1):
  print(max_pick(list,i))

