import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  br.readLine()

  val res = br.readLine().split(' ').map { it.toInt() }
    .fold(Pair(0, 1)) { acc, ai ->
      val (broken, cnt) = acc
      if(ai == cnt) Pair(broken, cnt + 1) else Pair(broken + 1, cnt)
    }

  val ans = if(res.second == 1) -1 else res.first
  println(ans)
}