import java.util.*

fun main() {
    val reader = System.`in`.bufferedReader()
    var tokenizer: StringTokenizer = StringTokenizer("")

    fun next(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
        return tokenizer.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextDouble() = next().toDouble()
    fun nextLine() = reader.readLine()

    fun solve() {
        var n = nextInt()
        var k = nextInt()

        var arr = nextLine().split(" ").map { it.toInt() }.sorted()


        var sum = 0
        for (i in 0..k-1)sum+=arr[i]

        println(sum)



    }

    solve()


}


