let () =
  let n = read_int () in
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let ans = Array.fold_left
      (fun (x, i) a -> if a = x then (x+1, i) else (x, i+1)) (1,0) arr in
  print_int (if (snd ans) = Array.length arr then -1 else snd ans)