
import java.io.InputStreamReader
import java.io.BufferedReader

fun _Do(){
    //
    val N = scanEx.nextInt()
    val K = scanEx.nextInt()
    val ia : Array<Int> = scanEx.intArray()
    
    //
    ia.sort()
    ia.reverse()
    
    var x = 0
    for(i in 0 until K){
        x += ia[i]
    }

    println(x)
    
}

val scanEx = ScannerEx()
//
fun main( argv : Array<String> ) {

    _Do()
}
//
class ScannerEx {
    
    //
    fun nextInt():Int{
        
        if( index <= -1 ||
            ls.count() == index)
        {
            index = 0
            ls = br.readLine().split(' ')
        }

        //
        var v = ls[index]!!.toInt()
        index += 1
        return v
    }
    
    var index:Int = -1 //
    var ls:List<String?> = emptyList()   //
    
    
    //
    fun intArray(): Array<Int> {
        
        val ss = br.readLine().split(' ')
        
        val type = Array<Int>(
                ss.size,
                { ss[it].toInt() }
        )
        
        return type
    }
    
    private var br = BufferedReader(InputStreamReader(System.`in`))
}


