fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val (n, k) = line.split(" ").map { it.toInt() }
    val line2 = readLine()!!.trim()
    val prices = line2.split(" ").map { it.toInt() }.take(n)

    val sortedPrices = prices.sortedBy {it}

    val price: Int = sortedPrices.take(k).sum()

    println("${price}")
}
