import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.List
import Data.Ord

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

diffs :: [Int] -> [Int]
diffs [_] = []
diffs [d1, d2] = [d1 - d2]
diffs (d1:d2:ds) = d1 - d2 : diffs (d2:ds)

solve :: Int -> Int -> [Int] -> Int
solve size 0 _ = size
solve size count (x:xs) = solve (size - x) (count - 1) xs

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  xs <- sortOn Down <$> readIntsLine
  let ds = sortOn Down $ diffs xs
  print $ solve (head xs - last xs) (min (length ds) (n - 1)) ds