import scala.io.StdIn._
object Main extends App {
  val input1 = readLine().split(" ").map(_.toInt)
  val input2 = readLine().split(" ").map(_.toInt).sorted.toList.reverse
  val n = input1(0)
  val k = input1(1)
  println(input2.take(k).sum)
}