import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  ans <- sum . map snd . take n . filter (even . fst) . zip [1..2*n] . take (2*n) . sortBy (\x y -> compare y x) . map read . words <$> getLine
  print ans