let n, m = stdin.ReadLine().Split() |> fun x -> (int x.[0], int x.[1])
let x = stdin.ReadLine().Split() |> Array.map int |> Array.sort
[1..m - 1] |> List.map (fun y -> x.[y] - x.[y - 1]) |> List.sortDescending |> List.skip (min (n - 1) (m - 1)) |> List.sum |> printfn "%d"