import Data.List

toInt :: String -> Int
toInt = read :: String -> Int

main = do
  [n, k] <- map toInt . words <$> getLine
  l <- map toInt . words <$> getLine
  print $ sum . take k . reverse . sort $ l
