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

func readIntPair() -> (Int, Int) {
    let line = readLine()!.split(separator: " ").map({Int($0)!})
    return (line[0], line[1])
}

let (N, K) = readIntPair()
let p = readIntArray().sorted()
var ans = 0
for i in 0..<K {
    ans += p[i]
}
print(ans)
