process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  var count = lines[0]
  var ary = lines[1].split(" ").map( x => Number(x) )
  var break_count = 0
  // 1から開始
  var tmp_count = 1
  var c = 0
  var j = true

  while (j) {
    if (ary.indexOf(break_count + 1) != -1) {
      break_count++
    } else {
      j = false
    }
  }
  if (break_count == 0) {
    console.log(-1)
  } else if (break_count == count) {
    console.log(0)
  } else {
    console.log(count - break_count)
  }
});
