fun main(){
    val n= readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val myArray = Array(1001) {0}
    for(i in 0 until n){
        myArray[i] = readLine()!!.toInt()
    }
    myArray.sort()
    var sum = 0
    for(i in 0 until k){
        sum += myArray[i]
    }
    println(sum)
}