module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d\n" @@ fun a -> a in
  let s = Array.fold_right (fun a -> IntSet.add (a lxor (a - 1))) as_ IntSet.empty in
  Printf.printf "%d\n" @@
  match
    Array.fold_left (fun (n, b, sum) i ->
      if sum land (1 lsl i) = 0
      then
        n, b, sum
      else
        n + 1,
        b && IntSet.mem ((1 lsl (i + 1)) - 1) s,
        sum lxor ((1 lsl (i + 1)) - 1))
    (0, true, Array.fold_left ( lxor ) 0 as_) @@
    Array.init 40 @@ ( - ) 39
  with
  | (n, true, _) -> n
  | (_, false, _) -> -1
