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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

ll dp[51][3100][2];

int main()
{
  int n;
  cin >> n;
  
  vi a(n);
  int x = 0;
  rep(i, n){
    cin >> a[i];
    x ^= a[i];
  }

  int ans = 0;
  for(int i = 30; i >= 0; i--){
    if(x & 1<<i){
      rep(j, n){
        if((a[j]^(a[j]-1)) == (1<<(i+1))-1){
          x ^= a[j]^(a[j]-1);
          ans++;
          break;
        }
      }
    }
  }

  if(x == 0){
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }

  return 0;
}
