import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()
val K = sc.nextInt()

fun main(args: Array<String>) {
    val l = Array(N) { sc.nextInt() }
    println(l.sorted().reversed().slice(0 until K).sum())

}
