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

func main() {
    let line = readInts()
    let k = line[1]
    let ps = readInts().sorted(by: <)
    
    var ans = 0
    for i in 0..<k {
        ans += ps[i]
    }
    
    print(ans)
}

main()
