import Data.List

difflist :: [Int] -> [Int]
difflist [] = []
difflist [x] = []
difflist (x:y:ls) = (y-x) : (difflist (y:ls))

rsort = sortOn (0-)

main :: IO ()
main = do
  [n,m] <- map read.words <$> getLine
  xs <- sort . (map read.words) <$> getLine
  let ns = sum.(drop (n-1)).rsort (difflist xs)
  if n >= m then print 0
    else putStrLn $ show $ sum.(drop (n-1)).rsort (difflist xs)