import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readString() -> String {
    return readLine()!
}

func readLines(times: Int) -> [String] {
    var array: [String] = []
    for _ in 0..<times {
        array.append(readLine()!)
    }
    return array
}

func readSeparatedStrings() -> [String] {
    return readLine()!.split(separator: " ").map({String($0)})
}

func readSeparatedInts() -> [Int] {
    return readLine()!.split(separator: " ").map({Int($0)!})
}


let nk = readSeparatedInts()
let n = nk[0]
let k = nk[1]

let prices = readSeparatedInts()
let sorted = prices.sorted()

var result = 0
for i in 0..<k {
    result += sorted[i]
}
print(result)
