import Control.Applicative
import Control.Monad
import Data.List
import Data.Ord
import qualified Data.Vector as V

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  ls <- sortOn Data.Ord.Down . map read . words <$> getLine

  print $ (sum . take m ) ls