from functools import reduce

from operator import xor



N, *A = list(map(int, open(0).read().split()))



x = reduce(xor, A)



ans = 0

K = x.bit_length()

for k in reversed(list(range(K))):

    if (x >> k) & 1:

        for a in A:

            t = a ^ (a - 1)

            if t == 2 ** (k + 1) - 1:

                x ^= t

                ans += 1

                break



if x == 0:

    print(ans)

else:

    print((-1))
from functools import reduce

from operator import xor



N, *A = list(map(int, open(0).read().split()))

x = reduce(xor, A)



memo = set(a ^ (a - 1) for a in A)



ans = 0

K = x.bit_length()

for k in reversed(list(range(K))):

    if (x >> k) & 1:

        t = (2 << k) - 1

        if t in memo:

            x ^= t

            ans += 1



if x == 0:

    print(ans)

else:

    print((-1))
from functools import reduce
from operator import xor

N, *A = list(map(int, open(0).read().split()))
x = reduce(xor, A)
ans = 0
K = x.bit_length()
for k in reversed(list(range(K))):
    if (x >> k) & 1:
        for a in A:
            t = a ^ (a - 1)
            if t == 2 ** (k + 1) - 1:
                x ^= t
                ans += 1
                break
if x == 0:
    print(ans)
else:
    print((-1))

from functools import reduce
from operator import xor

N, *A = list(map(int, open(0).read().split()))
x = reduce(xor, A)
memo = set(a ^ (a - 1) for a in A)
ans = 0
K = x.bit_length()
for k in reversed(list(range(K))):
    if (x >> k) & 1:
        t = (2 << k) - 1
        if t in memo:
            x ^= t
            ans += 1
if x == 0:
    print(ans)
else:
    print((-1))

+memo = set(a ^ (a - 1) for a in A) -        for a in A: -            t = a ^ (a - 1) -            if t == 2 ** (k + 1) - 1: -                x ^= t -                ans += 1 -                break +        t = (2 << k) - 1 +        if t in memo: +            x ^= t +            ans += 1