let n = stdin.ReadLine() |> int
let a = stdin.ReadLine().Split() |> Array.map int |> Array.toList

let rec f x ls =
 match ls with
 |[] -> x
 |hd :: tl -> (if x = hd then (f (x + 1) tl) else (f x tl))

let mae = f 1 a

if (mae = 1) then -1 else ((n - mae) + 1)
|>stdout.WriteLine