import Data.List
import Control.Applicative

solver :: Int->[Int]->Int
solver k list = sum $ take k $ reverse $ sort list

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [n, k] <- map read . words <$> getLine
    list <- map read . words <$> getLine
    -- 出力
    putStrLn $ show $ solver k list

