main :: IO ()
main = interact $ show . solve . map read . words

qsort :: Ord a => [a] -> [a]
qsort []     = []
qsort (x:xs) = lesser ++ [x] ++ greater
    where
        lesser  = [y | y <- xs, y <  x]
        greater = [z | z <- xs, z >= x]
        
solve :: [Int] -> Int
solve (n:k:hs)
    | n <= k    = 0
    | otherwise = sum . drop k . reverse . qsort $ hs