import Foundation

let input = readLine()!.components(separatedBy: " ").map{ Int($0)! }
let N = input[0]
let K = input[1]

let price = readLine()!.components(separatedBy: " ").map{ Int($0)! }
let lowToExpensive = price.sorted()

var totalPrice = 0

for i in 0...K - 1 {
    totalPrice += lowToExpensive[i]
}

print(totalPrice)