let id x = x

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

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

let () = 
  let ans = Array.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