import Data.Traversable
import Data.List
main :: IO ()
main = do
  (n:t:xs) <- map read . words <$> getLine
  ps <- map read . words <$> getLine
  putStrLn . show $ solve n ps

solve n ps =
  let sorted = reverse . sort . gap . sort $ ps
  in max 0 (sum $ drop (n-1) sorted)

gap :: [Int] -> [Int]
gap [] = []
gap (x:[]) = []
gap (x:y:xs) = abs (y - x) : (gap (y:xs))
