import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n , k = sc.nextInt()
    val l=List.fill(n)(sc.nextInt())

    println(l.sorted.reverse.take(k).sum)
  }
}
