fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    var ans = 0
    var f = false
    var n = 1
    var i = 0
    while (i < A.size) {
        if (A[i] == n) {
            n += 1
            f = true
        } else {
            ans += 1
        }
        i += 1
    }
    println(if (f) ans else -1)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }