import scala.io.StdIn

object Main extends App {
  val Array(n, k) = StdIn.readLine.split(" ").map(_.toInt)
  val ans = StdIn.readLine.split(" ").map(_.toInt)
    .sorted.takeRight(k).sum
  println(ans)
}