import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as U
import Data.Char
import Data.Maybe

readIntN :: Int -> IO (U.Vector Int)
readIntN m = U.unfoldrN m (B.readInt . B.dropWhile isSpace) <$> B.getLine

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  as <- readIntN m
  print $ fromMaybe (-1) $ solve n as

solve :: Int -> U.Vector Int -> Maybe Int
solve n as = if s > n then Nothing else Just (n - s)
  where s = U.sum as
