open System

[<EntryPoint>]
let main argv =
    let n = Console.ReadLine() |> int
    let a = Console.ReadLine().Split(' ') |> Array.map int
    let mutable ans, target = 0, 1
    for x in a do
        if x = target then
            ans <- ans + 1
            target <- target + 1

    printfn "%d" (if ans = 0 then -1 else (n - ans))
    0
