import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val k = sc.nextInt

  val ll = List.fill(n)(sc.nextInt)

  val res = ll.sorted.takeRight(k).sum

  println(res)
}
