n = int(eval(input()))

A = [int(eval(input())) for _ in range(n)]

m = 30

C = [False]*m

x = 0

for a in A:

  x ^= a

  for i in range(m):

    if a>>i & 1:

      C[i] = True

      break

total = 0

ans = 0

for i in range(m-1, -1, -1):

  if (x>>i & 1) ^ total:

    if C[i]:

      ans += 1

      total ^= 1

    else:

      print((-1))

      break

else:

  print(ans)
import sys

input = sys.stdin.readline

read = sys.stdin.read

import numpy as np



n = int(eval(input()))

A = np.array(read().split(), dtype=np.int64)

m = 30

C = np.zeros(m, dtype=bool)

used = np.zeros(n, dtype=bool)

x = 0

for a in A:

  x ^= a

for i in range(m):

  idx = np.where(A>>i & 1)

  if np.any(~used[idx]):

    C[i] = True

  used[idx] = True

total = 0

ans = 0

for i in range(m-1, -1, -1):

  if (x>>i & 1) ^ total:

    if C[i]:

      ans += 1

      total ^= 1

    else:

      print((-1))

      break

else:

  print(ans)
n = int(eval(input()))
A = [int(eval(input())) for _ in range(n)]
m = 30
C = [False] * m
x = 0
for a in A:
    x ^= a
    for i in range(m):
        if a >> i & 1:
            C[i] = True
            break
total = 0
ans = 0
for i in range(m - 1, -1, -1):
    if (x >> i & 1) ^ total:
        if C[i]:
            ans += 1
            total ^= 1
        else:
            print((-1))
            break
else:
    print(ans)

import sys

input = sys.stdin.readline
read = sys.stdin.read
import numpy as np

n = int(eval(input()))
A = np.array(read().split(), dtype=np.int64)
m = 30
C = np.zeros(m, dtype=bool)
used = np.zeros(n, dtype=bool)
x = 0
for a in A:
    x ^= a
for i in range(m):
    idx = np.where(A >> i & 1)
    if np.any(~used[idx]):
        C[i] = True
    used[idx] = True
total = 0
ans = 0
for i in range(m - 1, -1, -1):
    if (x >> i & 1) ^ total:
        if C[i]:
            ans += 1
            total ^= 1
        else:
            print((-1))
            break
else:
    print(ans)

+import sys + +input = sys.stdin.readline +read = sys.stdin.read +import numpy as np + -A = [int(eval(input())) for _ in range(n)] +A = np.array(read().split(), dtype=np.int64) -C = [False] * m +C = np.zeros(m, dtype=bool) +used = np.zeros(n, dtype=bool) -    for i in range(m): -        if a >> i & 1: -            C[i] = True -            break +for i in range(m): +    idx = np.where(A >> i & 1) +    if np.any(~used[idx]): +        C[i] = True +    used[idx] = True