import Data.List (sortBy)

main = do
  line1 <- getLine
  line2 <- getLine
  let
    [_,k] = map read $ words line1 :: [Int]
    dat = map read $ words line2 :: [Int]
    ans = sum $ take k $ sortBy (\x y -> y `compare` x) dat
  putStrLn $ show ans
