local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max

local function getxor(x, y)
  local ret = 0
  local mul = 1
  while(0 < x or 0 < y) do
    if((x % 2) + (y % 2) == 1) then
      ret = ret + mul
    end
    x, y, mul = mfl(x / 2), mfl(y / 2), mul * 2
  end
  return ret
end

local n = io.read("*n")
local tot = 0
local cutpos = {}
for i = 1, 32 do cutpos[i] = false end
for i = 1, n do
  local a = io.read("*n")
  tot = getxor(tot, a)
  local pos = 1
  while a % 2 == 0 do
    pos = pos + 1
    a = mfl(a / 2)
  end
  cutpos[pos] = true
end
local tgt = {}
local isok = true
while 0 < tot do
  table.insert(tgt, tot % 2 == 1)
  tot = mfl(tot / 2)
end
local cnt = 0
for i = #tgt, 1, -1 do
  if tgt[i] then
    if cutpos[i] then
      cnt = cnt + 1
      for j = 1, i - 1 do
        tgt[j] = not tgt[j]
      end
    else
      isok = false
      break
    end
  end
end
print(isok and cnt or -1)
