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

    var searchFor = 1
    var ans = 0
    for(i in a) {
        if(searchFor == i) {
            searchFor++
        } else {
            ans++
        }
    }
    println(if(ans==n) -1 else ans)
}
