open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let Mod = (1e9|>int64)+7L
[<EntryPoint>]
let main argv =
    let N = R int
    let a = RS int
    let mutable cur = 1
    for i in [0..N-1] do
        if cur=a.[i] then cur <- cur+1
    if cur=1 then -1 else N-cur+1
    |>stdout.WriteLine
    0
