#include <bits/stdc++.h>

int solve();

int main()
{
	printf("%d\n", solve());

	return 0;
}

int solve()
{
	int N;
	scanf("%d", &N);
	std::vector<int64_t> a(N);
	for (auto& e: a) scanf("%lld", &e);

	int64_t all_xor{};
	for (auto& e: a) all_xor ^= e;

	bool exist[32]{};
	for (auto& e: a)
	{
		int digit{};
		while (~e >> digit & 1) digit++;
		exist[digit] = true;
	}

	int count{};
	for (int i{}; i < 32; i++)
	{
		if (((all_xor >> i) & 1) ^ ((all_xor >> (i + 1)) & 1) == 0)
			continue;
		if (!exist[i]) return -1;
		count++;
	}

	return count;
}