object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN, datK) = readLine.split(" ").map(_.toInt)
    val datL = readLine.split(" ").map(_.toInt)

    val ans = datL.sorted.reverse.slice(0, datK).sum

    println(ans)
  }
}
