let n, ans = read_int (), ref 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let _ = Array.fold_left (fun c a -> if a = c then c + 1 else (incr ans; c)) 1 a_s
let _ = Printf.printf "%d\n" @@ if !ans = n then -1 else !ans