import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readLine.toInt
  val a = in.readLine.split(" ").map(_.toInt)

  var cnt = 1
  var break = 0;
  for(i <- 0 until n) {
    if(a(i) == cnt) {
      cnt += 1
    }
    else {
      break += 1
    }
  }

  val ans = if(cnt == 1) -1 else break
  println(ans)
}