function Main(input) {
    var N = parseInt(input[0], 10);
    var K = parseInt(input[1], 10);
    var H = input.slice(2).map(a => parseInt(a, 10));

    var sorted = H.sort((a, b) => b - a);

    var needAtk = sorted.slice(K);

    var sum = 0;

    for (var i = 0; i < needAtk.length; i++) {
        sum += needAtk[i];
    }

    console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));