import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List ( sortBy )
import qualified Data.Vector.Unboxed as U


getParm :: IO [Int]
getParm = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  n <- readLn :: IO Int
  ass <- getParm
  print $ g n ass

sort' :: [Int] -> [Int]
sort' = sortBy (flip compare)

f :: Int -> [Int] -> U.Vector Int
f n ass = U.take n $ h ass'
  where
    h :: [Int] -> U.Vector Int
    h [] = U.empty
    h [b] = U.singleton b
    h (_:b:bs) = b `U.cons` h bs

    ass' = sort' ass

g n = U.sum . f n