let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let xs = Array.init m @@ fun _ -> Scanf.scanf "%d " @@ fun x -> x in
  Array.sort compare xs;
  let ds = Array.init (m - 1) @@ fun i -> xs.(i + 1) - xs.(i) in
  Array.sort compare ds;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@
  Array.sub ds 0 @@ max 0 @@ m - n
