N = int(eval(input()))

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



A.sort(reverse=True, key=lambda a: (a & -a))



xor = 0

for a in A:

    xor ^= a



left = 0

ans = 0



for digit in range(xor.bit_length() + 1)[:: -1]:

    if (xor & (1 << digit)) > 0:

        while left < N and ((A[left] & -A[left]).bit_length() - 1) > digit:

            left += 1



        if left >= N or ((A[left] & -A[left]).bit_length() - 1) != digit:

            print((-1))

            exit()



        ans += 1

        xor ^= ((1 << (digit + 1)) - 1)



print(ans)
N = int(eval(input()))

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



digits = set()



for a in A:

    digits.add((a & -a).bit_length() - 1)



xor = 0

for a in A:

    xor ^= a



ans = 0



for digit in range(xor.bit_length() + 1)[:: -1]:

    if (xor & (1 << digit)) > 0:

        if digit in digits:

            ans += 1

            xor ^= ((1 << (digit + 1)) - 1)

        else:

            print((-1))

            exit()



print(ans)
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
A.sort(reverse=True, key=lambda a: (a & -a))
xor = 0
for a in A:
    xor ^= a
left = 0
ans = 0
for digit in range(xor.bit_length() + 1)[::-1]:
    if (xor & (1 << digit)) > 0:
        while left < N and ((A[left] & -A[left]).bit_length() - 1) > digit:
            left += 1
        if left >= N or ((A[left] & -A[left]).bit_length() - 1) != digit:
            print((-1))
            exit()
        ans += 1
        xor ^= (1 << (digit + 1)) - 1
print(ans)

N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
digits = set()
for a in A:
    digits.add((a & -a).bit_length() - 1)
xor = 0
for a in A:
    xor ^= a
ans = 0
for digit in range(xor.bit_length() + 1)[::-1]:
    if (xor & (1 << digit)) > 0:
        if digit in digits:
            ans += 1
            xor ^= (1 << (digit + 1)) - 1
        else:
            print((-1))
            exit()
print(ans)

-A.sort(reverse=True, key=lambda a: (a & -a)) +digits = set() +for a in A: +    digits.add((a & -a).bit_length() - 1) -left = 0 -        while left < N and ((A[left] & -A[left]).bit_length() - 1) > digit: -            left += 1 -        if left >= N or ((A[left] & -A[left]).bit_length() - 1) != digit: +        if digit in digits: +            ans += 1 +            xor ^= (1 << (digit + 1)) - 1 +        else: -        ans += 1 -        xor ^= (1 << (digit + 1)) - 1