import Data.List
import Data.Ord
main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    as <- map read . words <$> getLine :: IO [Int]
    let ans = sum $ take k $ sortOn Down as
    print ans
