import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val k = scn.nextInt()
	val p = IntArray(n){scn.nextInt()}.also{it.sort()}
	println(p.slice(0 until k).sum())
}