object Main {
  def main(args: Array[String]): Unit = {
    val factors     = io.StdIn.readLine.split(" ").map{_.toInt}
    val item_values = io.StdIn.readLine.split(" ").map{_.toInt}.sorted
    var sum         = 0

    ( 0 until factors(1) ).foreach { i =>
      sum += item_values(i)
    }

    println( sum )
  }
}