import scala.io.StdIn

object Main extends App {

  val Array(n, k) = StdIn.readLine().split(" ").map(_.toInt)
  val a = StdIn.readLine().split(" ").map(_.toInt)
  val as = a.sorted(Ordering[Int].reverse)
  println(as.take(k).sum)
  
}
