let () =
    let main () =
        let n = Scanf.scanf "%d" (fun n -> n) in
        let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun k -> k)) in
        let rec loop i cur =
            if i = n then cur else
                let cur = if a.(i) = cur then cur + 1 else cur in
                loop (i + 1) cur
        in
        let c = loop 0 1 in
        let r = if c = 1 then (-1) else n - c + 1 in
        Printf.printf "%d\n" r
    in
    main ()