fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val t = readLine()!!.split(' ').map { it.toInt() }
    var cur = 1
    t.forEach { if (cur == it) cur++ }
    println(if (cur == 1) -1 else n - cur + 1)
}