fun main() {
    val k = readLine()!!.split(' ')[1].toInt()
    var mink = 10000
    val p = readLine()!!.split(' ').map { it.toInt() }
    for(i in p.indices) {
        if (i < k || mink > p[i]) mink = p[i]
    }
    println(p.filter { it <= mink }.sum())
}