import sequtils, strutils, math
import macros
macro unpack(s:seq, n:static[int]): auto =
  let t = genSym()
  result = quote do:(let `t` = `s`;())
  when NimMajor == 0 and NimMinor <= 17:
    for i in 0..<n: result[0][1].add(quote do:(`t`[`i`]))
  else:
    for i in 0..<n: result[1].add(quote do:(`t`[`i`]))

let
  (n, m) = stdin.readline.split.map(parseInt).unpack(2)
  bs = stdin.readline.split.map(parseInt)

if n < sum(bs):
  echo -1
else:
  echo n-sum(bs)
