import java.util
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, k = sc.nextInt()
    var l = List[Int]()
    for(i <- 1 to n) {
      l = sc.nextInt() :: l
    }
    l.sorted(Ordering[Int].reverse)
    println(l.take(k).sum)
  }
}
