program r20718a

implicit none
integer :: n, i, j, m
integer, allocatable :: a(:)

m = 0

read *, n
allocate(a(1:3*n))

read *, a(:)

!print *, a(:)

do i = 1, 3*n
 do j = 1, 3*n-i+1
  if (a(j) > a(j+1)) then
   m = a(j)
   a(j) = a(j+1)
   a(j+1) = m
  end if
 end do
end do

!print *, a(:)

m = 0

do i = n+1, 2*n
 m = a(i) + m
end do

print *, m

end program r20718a   