function Main(input) {
  const data = input.trim()
  const array = data.split('\n')
  const N = parseInt(array[0])
  const list = array[1].split(' ').map(s => parseInt(s))

  if (N === 1) {
    console.log(0)
    return
  }

  let count = 0;
  let current = 1;
  for(let i = 0; i < N; ++i) {
    const n = list[i]
    if (n === current) {
      current++
    } else {
      count++;
    }
  }
  
  if (count === N) {
    console.log(-1)
  } else {
    console.log(count)
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));