let k =
    stdin.ReadLine().Split()
    |> Array.map int
    |> fun ary -> ary.[1]

let prices =
    stdin.ReadLine().Split() |> Array.map int

prices
|> Array.sort
|> Array.take k
|> Array.sum
|> printfn "%d"
