fun main() {
    val s = Integer.parseInt(readLine()?.split(" ")?.map{Integer.parseInt(it)}?.slice(1..1)?.sum().toString())
    println(readLine()?.split(" ")?.map { Integer.parseInt(it) }?.sorted()?.slice(0 until s)?.sum() ?: return)
}