import Data.List

main = do
    [n, m] <- map read . words <$> getLine
    xs <- map read . words <$> getLine
    let xs' = reverse . sort $ xs
        dxs = zipWith (-) xs' (tail xs')
        dxs' = reverse . sort $ dxs
        width = head xs' - last xs'
    print $ width - sum (take (n - 1) dxs')