import Data.List
import Data.Int (Int64)

main = do
  [n, k] <- map read . words <$> getLine
  h <- map read . words <$> getLine
  print (solve k h)

solve :: Int64 -> [Int64] -> Int64
solve k h
  = sum $ map f $ zip [0..(length h)] $ reverse $ sort h
  where
    f :: (Int, Int64) -> Int64
    f (i, num)
      | fromIntegral i < k = 0
      | otherwise = num