Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(input){
    var args = input.split('\n');
    var N = parseInt(args[0].split(' ')[0], 10);
    var K = parseInt(args[0].split(' ')[1], 10);
    var a = args[1].split(' ').map(a => parseInt(a, 10));
    a.sort( (a,b) => (a<b ? -1 : 1) );
    var total = 0;

    for(var i=0; i<K; i++){
        total += a.pop();
    }

    console.log(total);
}