function Main(input) {
  var lines = input.split('\n');

  var num = Math.floor(lines[0]);
  
  var array = lines[1].split(' ').map(str => parseInt(str, 10));
  
  var currentNum = 1;
  var hummered = [];
  var flag = true;
  
  for (var i = 0; i < array.length; i++) {
    if (array[i] !== currentNum) {
      hummered.push(array[i]);
    } else if (array[i] === currentNum) {
      currentNum++;
    }
  }
  
  if (hummered.length === num) {
    var j = 1;
    for (var i = 0; i < num; i++) {
      if (array[i] !== j) {
        flag = false;
      }
    }
    if (flag) {
      console.log('1');
    } else {
      console.log('-1');
    }
  } else {
    console.log(hummered.length);
  }
  
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));