import Foundation

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

P.sort()


for tmp in 0 ..< K {
    result += P[tmp]
}

print(result)