fun main() {
    val inLine1 = readLine()!!.split(" ").map(String::toInt)
    val inLine2 = readLine()!!.split(" ").map(String::toInt)
    val n = inLine1[0]
    val k = inLine1[1]

    var pList = inLine2.sorted()
    var result = 0
    var i = 0
    while(i < k){
        result += pList[i]
        i++
    }
    println(result)
}