fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }

    var next = 1
    var crashed = 0

    aa.forEach {
        if (it == next) {
            next++
        } else {
            crashed++
        }
    }

    if (crashed == n) {
        println(-1)
    } else {
        println(crashed)
    }
}