import Data.List

solver::[Int]->Int->Int
solver xs n = sum (take n (sortBy (\x y-> compare y x) xs))

main::IO()
main=do
  nkc<-getLine
  let n:k:[]=map read (words nkc)
  datc<-getLine
  let dat = map read (words datc)
  print (solver dat k)