function Main (input) {
  input = input.split("\n").map(inp => inp.split(" ").map(Number));
  var K = input[0][1];
  var l = input[1];
  var ans = 0;
  l.sort((a, b) => b > a);
  for (var i = 0; i < K; i++) {
    ans += l[i];
  }
  console.log(ans);
}

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