import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List

solve :: [Int] -> Int -> Int
solve = ((.) sum ) . (flip take) . reverse . sort

main :: IO ()
main = do
    [n, k] <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    a <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
    print $ solve a k
