fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val block = readLine()!!.split(" ").map { it.toInt() }
    var cur = 1
    for(i in block) {
        if(cur == i) {
            cur++
        }
    }
    if(cur == 1) {
        println(-1)
    } else {
        println(n - (cur-1))
    }
}