fun main(args: Array<String>) {
  	var (N, K) = readLine()!!.split(" ").map{ it.toInt() }
    var xList = readLine()!!.split(" ").map(String::toInt)
    
    var value = 0
    
    xList = xList.sorted()
    
    for (n in 0 until K) {
        value += xList[n]
    }

    println(value.toString())
}