
import Data.List (sortBy, sort)

diff :: Num a => [a] -> [a]
diff [_] = []
diff (x:y:xs) = y-x : diff (y:xs)

main :: IO ()
main = do
  n:m:_ <- map read . words <$> getLine
  ds <- sortBy (flip compare) . diff . sort . map read . words <$> getLine
  if n >= m then
      print 0
  else
      print $ sum $ drop (n-1) ds
