let () =
  Scanf.scanf "%d %d\n" @@ fun n k ->
  let hrr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let () = Array.fast_sort (fun x y -> y-x) hrr in
  let all = Array.fold_left (+) 0 hrr in
  let sum = ref 0 in
  if n > k then
    for i = 0 to k - 1 do
      sum := !sum + hrr.(i)
    done;
  Printf.printf "%d\n" (if n <= k then 0 else all - !sum)
