object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val Array(n,k)=input.split("\n")(0).split(" ").map(_.toInt)
    val ls=input.split("\n")(1).split(" ").map(_.toInt)
    ls.sortWith(_>_).take(k).sum.toString
  }
}
