let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let ans = Array.fold_left (fun ans a -> if ans + 1 = a then a else ans) 0 as_ in
  Printf.printf "%d\n" @@ if ans = 0 then -1 else n - ans
