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