import Control.Applicative
import Data.List

main :: IO ()
main = do
  [n, _] <- f
  solve n <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: Int -> [Int] -> Int
solve n = sum . drop (n-1) . sortBy (flip compare) . (tail >>= zipWith (-)) . sort
