fun main(args:Array<String>){
    val n = readLine()!!.split(" ").map { it.toLong() }
    val s = readLine()!!.split(" ").map { it.toLong() }.sorted().toMutableList()
    var count: Long

    if(n[1] >= n[0]){
        println("0")
    }else if(n[1].toInt() == 0){
        println(s.sum())
    }else{
        val a = n[0] - n[1]
        val f = s.filterIndexed{idx, item -> idx < a}
        count = f.sum()
        println(count)
    }
}

