fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val prices = Array(n){
        readLine()!!.toInt()
    }

    print(prices.sorted().take(k).sum())
}