#include <bits/stdc++.h>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> v(n, 0);

    int s = 0;

    for(int i = 0; i < n; ++i) {
        cin >> v[i];
        s ^= v[i];
    }
    
    vector<int> used(n, 0);
    int ans = 0;
    for(int bit = 29; bit >= 0; --bit) {
        if((1 << bit) & s) {
            ans++;
            bool has = false;
            for(int i = 0; i < n; ++i) {
                if(not used[i] && (v[i] & (-v[i])) == (1 << bit)) {
                    has = true;
                    used[i] = 1;
                    s ^= ((1 << bit) - 1);
                    s ^= (1 << bit);
                    break;
                }
            }
            if(not has) {
                cout << "-1";
                return 0;
            }
        }
    }

    cout << ans << "\n";
}