import Data.List                                                                                                           
                                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [n,m] <- map read . words <$> getLine :: IO [Int]                                                                        
  xs <- sort . map read . words <$> getLine :: IO [Int] -- x1,x2,...,xm                                                    
  let ys = (1,0) : zipWith (\x y -> (y,y-x)) xs (tail xs)  -- list of x and distance of neighbour                          
      zs = map fst $ take (n - 1) $ sortBy (\(_,a) (_,b) -> compare b a) ys -- elements that have biggest distance         
  print $ sum $ map solve $  groupBy (\_ y -> y `notElem` zs) xs                                                           
                                                                                                                           
                                                                                                                           
solve :: [Int] -> Int                                                                                                      
solve [] = 0                                                                                                               
solve [_] = 0                                                                                                              
solve (x:xs) = last xs - x