import Foundation

let inputs = readLine()!.split(separator: " ").map{ Int($0)! }
let n = inputs[0]
let k = inputs[1]

let p = readLine()!.split(separator: " ").map{ Int($0)! }

print(p.sorted().prefix(k).reduce(0, +))
