fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val A = readLine()!!.split(" ").map { it.toInt() }
  var num = 1
  var count = 0
  for (a in A) {
    if (a == num) {
      num++
    } else {
      count++
    }
  }
  println(if (count == N) -1 else count)
}
