import Foundation
let line = readLine()!.components(separatedBy: " ").map { Int($0)! }
let N = line[0]
let K = line[1]
let p = readLine()!.components(separatedBy: " ").map { Int($0)! }.sorted()

var minTotal = 0
for i in 0..<K {
    minTotal += p[i]
}
print(minTotal)
