import Control.Applicative import Control.Monad import Data.List solve :: Int -> [Int] -> Int solve c ai = case f c (sortBy (flip compare) ai) 0 of [] -> -1 list -> minimum . take 100 $ list where f 0 _ ans = return ans f _ [] _ = [] f rest (x:xs) ans = do let m = rest `div` x i <- [m,m-1..0] f (rest - i*x) xs (ans + i) main :: IO () main = do c <- readLn :: IO Int n <- readLn :: IO Int ai <- map read . words <$> getLine :: IO [Int] print $ solve c ai