import Data.List

func n (x:xs)
    | n > 0 = x + func (n-1) xs
    | otherwise = 0
func n [] = 0

main :: IO ()
main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    h <- map read . words <$> getLine :: IO [Int]
    print $ func (n-k) (sort h)