import scala.io.StdIn

object Main extends App {
  val Array(_,k) = StdIn.readLine().split(' ').map(_.toInt)
  val prices = StdIn.readLine().split(' ').map(_.toInt).sorted
  val out = prices.take(k).sum
  println(out)

}