main :: IO () main = interact $ show . solve . map read . words solve :: [Int] -> Int solve (k:n:_:as) | kn >= pas = kn - pas | otherwise = -1 where pas = sum as kn = k * n