let id x = x

let repeat f = 
  let rec loop lst = function
    | 0 -> List.rev lst
    | n -> loop (f () :: lst) (n-1) in
  loop []

let n = Scanf.scanf "%d\n" id

let a = repeat (fun () -> Scanf.scanf " %d" id) n

let () = 
  let ans = List.fold_left (fun v i -> if i = (v + 1) then v + 1 else v) 0 a in
  print_int @@ if ans = 0 then -1 else n - ans