let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let ps = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun p -> p in
  Array.sort compare ps;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@
  Array.sub ps 0 k
