function main(s) {
	s = s.split("\n");
	t = s[0].split(" ").map(x => Number(x));
	function cmp(x, y) {
		return Number(x) - Number(y);
	}
	l = s[1].split(" ").map(x => Number(x)).sort(cmp).reverse();
	console.log(l);
	var x = 0;
	for (var i = 0; i < t[1]; i++) {x += l[i];}
	console.log(x);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

