function main (input) {
    const N = input.split('\n')[0].split(' ')[0];
    const K = input.split('\n')[0].split(' ')[1];
    const l = input.split('\n')[1].split(' ')
                 .map(function(e){return Number(e);})
                 .sort(function(a,b){return b-a;});
    ans = 0;

    for (var i = 0; i < K; i++) {
        ans = ans + l[i];
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));