import java.util.Arrays;
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val K = input.nextInt()
    val p = IntArray(N)
    
    for (i in 0..N-1) {
      p[i] = input.nextInt()
    }
    
    Arrays.sort(p)
    
    var totalPrice = 0;
    for (i in 0..K-1) {
      totalPrice += p[i] 
    }
    
    println(totalPrice)
  }
}