'use strict'
 
function main(n) {
  let N = n.split("\n")[0].split(" ")[0];
  let K = n.split("\n")[0].split(" ")[1];
  let l = n.split("\n")[1].split(" ");
  let ans = 0;
  let lSort = l.sort((a,b)=>{
  	return a-b;
  }).reverse();
  
  for(let i = 0; i < K; i++){
  	ans += lSort[i] * 1;
  }
  console.log(ans);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));