import Data.List import Data.Ord main = do [n,k] <- words <$> getLine (a1:alist) <- sortOn Down . (map read :: [String] -> [Int]) . words <$> getLine let result = a1 + (sum $ take (read k - 1) $ sortOn Down $ filter (>0) $ alist) print result