import Data.List
import Data.Ord

solve :: Int -> Int -> [Int] -> Int
solve n m xs
  | n >= m = 0
  | True = sum $ drop (n - 1) $ sortBy (comparing Down) $ map (\(x, y) -> x - y) $ zip rs xs
  where
    _:rs = xs


main :: IO()
main = do
  (n:m:_) <- fmap (\s -> read s :: Int) <$> words <$> getLine
  xs <- fmap (\s -> read s :: Int) <$> words <$> getLine
  print $ solve n m $ sort xs
