#include <bits/stdc++.h>
using namespace std;
const int sz = 31;
int ans = 0;
vector<int> base(sz, 0);
bool sol(int k) {
  for (int i = 0; i < sz; ++i) {
    int c = k >> i & 1;
    base[i] |= (c << ans);
  }
  vector<int> g = base;
  for (int i = 0; i < ans; ++i) {
    for (int j = i; j < sz; ++j) {
      if (g[j] >> i & 1) {
        swap(g[i], g[j]);
        break;
      }
    }
    for (int j = i + 1; j < sz; ++j) {
      if (g[j] >> i & 1) g[j] ^= g[i];
    }
  }
  bool is = 0;
  for (int i = ans; i < sz; ++i) {
    if (g[i] >> ans & 1) is = 1;
  }
  if (is) {
    ++ans;
    return 0;
  } else {
    for (int i = 0; i < sz; ++i)
      if (base[i] >> ans & 1) base[i] -= (1 << ans);
    return 1;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int cur = 0;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    cur ^= k;
    if (!sol(cur)) cur = 0;
  }
  if (cur) {
    int x = 0;
    for (int i = 0; i < sz; ++i) {
      int y = 0;
      for (int j = 0; j < ans; ++j) y ^= (base[i] >> j & 1);
      x ^= (y << i);
    }
    if (x == cur) ans = -1;
  }
  if (ans == 0) ans = -1;
  cout << ans << '\n';
}
