import Data.List(sort)
main = do
    [_,k] <- map read . words <$> getLine :: IO [Int]
    a <- map read . words <$> getLine :: IO [Int]
    print $ f k a
        where f n = sum . (take n) . reverse . sort