const main = input => {
  const [n, , ...a] = input.trim().split(/ |\n/).map(e => parseInt(e))
  return Math.max(a.reduce((a, c) => a - c, n), -1)
}

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));