import Data.List
f [_] = []
f (x:y:xs) = (y-x) : f (y:xs)
main = do
  [n,m] <- map (read::String->Int) . words <$> getLine
  xs <- map (read::String->Int) . words <$> getLine -- length of xs = m
  let nn = n-1
  let ys = sortOn (0 -) $ f $ sort xs
  print $ sum $ drop nn ys
