'use strict';
const main = input => {
  let n = parseInt(input[0]), a = input[1].split(' ').map(val => parseInt(val));
  // console.log(n, a);
  let id = 0, count = 0;
  a.map(val => {
    if (val-1 == id) {
      id++;
    } else {
      count++;
    }
  })
  if (!id) return console.log(-1);
  console.log(count);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));