import java.util.Scanner

/**
  * Created by goryudyuma on 2017/07/16.
  */


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val K = sc.nextInt()
    val arr: Array[Int] = new Array[Int](N)

    for (i <- 0 until N) {
      arr(i) = sc.nextInt()
    }
    val sortedArr = arr.sorted.reverse

    var ans = 0
    for (i <- 0 until K) {
      ans += sortedArr(i)
    }

    println(ans)
  }
}
