import Foundation

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

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