open System

[<EntryPoint>]
let main argv =
    let [|n; k|] = stdin.ReadLine().Split() |> Array.map int
    let a = stdin.ReadLine().Split() |> Array.map int
    let b = Array.sort a 
    b.[0..k-1] |> Array.sum |> printf "%d"

    0 
