object Main extends App {


  val Array(n, k) = scala.io.StdIn.readLine().split(" ").map(_.toInt)
  val pArr = scala.io.StdIn.readLine().split(" ").map(_.toInt)

  def solve(): Int = {
    pArr.sorted.take(k).sum
  }

  println(solve())

}
