function Main(input) {
  /** @type {number[]} */
  const aList = input[1].split(' ').map(Number);

  var nextBrick = 1;
  for (var i = 0; i < aList.length; i++) {
    if (aList[i] === nextBrick) {
      nextBrick++;
    }
  }

  const answer = nextBrick > 1 ? (aList.length - (nextBrick - 1)) : -1;

  console.log(answer);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));