import Control.Applicative import Data.List solve l ws = subtract 1 $ length $ unfoldr go (l,ws) where go (0,[]) = Just (0, (-1,[])) go (_,[]) = Nothing go (m,x:xs) | m >= 0 = Just (m, (m-x,xs)) | otherwise = Nothing main = do l <- (read :: String -> Int) <$> getLine n <- getLine ws <- fmap (read :: String -> Int) . words <$> getLine print $ solve l $ sort ws