#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    int n;
    cin >> n;
    lli a[100500];
    rep(i, n) cin >> a[i];
    lli x = 0;
    rep(i, n) x ^= a[i];
    int ans = 0;
    for (int i = 32; i >= 1; i--) {
        rep(j, n)
        {
            if (((1LL << i) - 1)
                == (a[j] ^ (a[j] - 1))) {
                if ((x >> (i - 1)) & 1) {
                    x ^= a[j] ^ (a[j] - 1);
                    ans++;
                }
            }
        }
    }
    cout << (x == 0 ? ans : -1) << endl;
}
