function Main(input) {
  var inputs = input.split("\n");
  var k = parseInt(inputs[0].split(" ")[1], 10);
  var l = inputs[1].split(" ").map(e => parseInt(e, 10)).sort((a, b) => b - a);
  var sum = 0;
  for (var i = 0; i < k; i++) sum += l[i];
  console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));