fun main() {
    val firstLine = readLine()!!
    val prices = readLine()!!.split("\\s+".toRegex()).map { it.toInt() }.toIntArray()
    val n = firstLine[0] - '0'
    val k = firstLine[2] - '0'
    val sortedPrices = prices.apply { sort() }
    println(sortedPrices.take(if (k > n) n else k).sum())
}