fun main() {
    val (n, k) = next2Int()
    val prices = nextIntArray(n)
    prices.sort()
    println(prices.slice(0 until k).sum())
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(),nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }