import Foundation
var o = 0
let arr=readLine()!.split{$0==" "}.map{Int(String($0))!}
let n=arr[0]
let a=arr[1]
var arr2=readLine()!.split{$0==" "}.map{Int(String($0))!}
arr2.sort()
for i in 0..<a {
   o += arr2[i]
}
print(o)