fun main() {

    val input = readLine()?.split(' ')?.map { it.toInt() } ?: listOf()

    val p = readLine()?.split(' ')?.map { it.toInt() } ?: listOf()

    val result  =p.sorted().subList(0,input[1]).sum()


    println(result)
}