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

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

answer=[]
for i in range(1,N+1):
  answer.append(max_pick(list,i))

print(answer)
