'use strict'
function Main(input) {
    input = input.split("\n");
    const n = parseInt(input[0].split(' ')[1], 10)
    const arr = input[1].split(' ').map(v => parseInt(v, 10)).sort((a,b) => b - a)
    let sum = 0;
    for (let i = 0; i < n; i ++) {
        sum += arr[i]
    }
    console.log(sum)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));