"use strict";
// import bigInt from 'big-integer'

const Main = input => {
  input = input.trim().split("\n");
  const n = input[0];
  const array = input[1].split(" ");

  const map = new Map();
  let next = 1;
  for (let i = 0; i < n; i++) {
    const num = parseInt(array[i]);
    if (next === num) {
      if (!map.get(num)) {
        map.set(num, 1);
        next++;
      }
    }
  }

  console.log(map.size === 0 ? -1 : n - map.size);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
