let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let xs = Array.init m @@ fun _ -> Scanf.scanf " %d" (+) 0
let ds = if n >= m then (print_endline "0"; exit 0); Array.(sort (-) xs; init (m - 1) @@ fun i -> xs.(i + 1) - xs.(i))
let _ = Array.(sort (fun x y -> y - x) ds; sub ds 0 @@ n - 1 |> fold_left (+) 0 |> (-) @@ xs.(m - 1) - xs.(0) |> Printf.printf "%d\n")