"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
const k = input[0].split(' ').map(x => +x)[1];
const hs = input[1]
    .split(' ')
    .map(x => +x)
    .sort((a, b) => b - a)
    .slice(k);
console.log(!hs.length ? 0 : hs.reduce((ac, cu) => ac + cu));
