import Data.List
import Data.Array
import Control.Monad

main = do
 [n, k] <- (map read . words) <$> getLine
 ln <- map read . words <$> getLine
 print  (solve ln k)

solve :: [Int] -> Int -> Int
solve ln k = sum (take k (reverse (sort ln)))

