import Data.List (sort)
import Data.Bool (bool)

main :: IO ()
main = do
  [n :: Integer, m :: Integer] <- map read . words <$> getLine
  (xs :: Integer) <- sort . map read . words <$> getLine
  let
      ds = reverse $ sort $ zipWith subtract xs (tail xs)
      gaps = sum $ take (n - 1) ds
  print $ bool 0 (last xs - head xs - gaps) (n < m)
