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