import Foundation

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

while (count < type) {
    priceList.append(Int(readLine()!)!)
    count += 1
}

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

print(price)