import Data.List

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  ls <- map read . words <$> getLine :: IO [Int]
  print $ sum $ take k $ sortBy (\a b -> compare b a) ls
