var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/g);
var k = input[0].split(/\s/g)[1];
var l = input[1].split(/\s/g).map(function(s){return s - 0;}).sort();
console.log(l.slice(l.length - k).reduce(function(s, a){return s + a;}));