import Foundation

var type: Int = Int(readLine()!)!
var min: Int = Int(readLine()!)!
var priceList: [Int] = []
var price = 0

for _ in 0 ..< type {
    priceList.append(Int(readLine()!)!)
}

priceList.sort {$0 < $1}
for j in 0 ... min - 1 {
    price += priceList[j]
}

print(price)