import Data.List
import Data.Ord

main = do 
    [n,m] <- map read . words <$> getLine :: IO [Int]
    xs <- sort . map read . words <$> getLine :: IO [Int]
    let xs' = sortBy (comparing Down) $ map abs $ zipWith (-) xs (tail xs)
    print $ sum xs' - (sum $ take (n-1) xs')