function main(input) {
  var N = input[0].split(" ")[0]-0;
  var K = input[0].split(" ")[1]-0;
  var ans = input[1].split(" ").map(v=>v-0).sort((a,b)=>b-a).filter((v,i)=>i<K).reduce((a,b)=>a+b);
  
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))
