"use strict";

const main = arg => {
    const K = arg.split("\n")[0].split(" ")[1];
    const l = arg.split("\n")[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>b-a);
    
    console.log(l.slice(0, K).reduce((m,n)=>m+n));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
