Scanf.scanf "%d %d" (fun n m ->
    let x = Array.init m (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
    Array.sort compare x;
    let xd = Array.init (m - 1) (fun i -> x.(i + 1) - x.(i)) in
    Array.sort compare xd;
    let rec loop i acc =
        if i < max 0 (m - n) then acc else
            loop (i - 1) (acc - xd.(i))
    in
    loop (m - 2) (x.(m - 1) - x.(0)) |> Printf.printf "%d\n"
)