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

    val snake = ls.sorted.splitAt(ls.length - k)

    println(snake._2.sum)
  }
}
