#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1000000000;
const ll LINF = 1001002003004005006ll;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
struct IOSetup {
  IOSetup() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(12);
  }
} iosetup;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++)
    os << v[i] << (i + 1 == v.size() ? "" : " ");
  return os;
}
struct BinaryBasis {
  vector<ll> basis;
  bool update;
  BinaryBasis() : update(false) {}
  bool add(ll bit) {
    for (auto &p : basis) bit = min(bit, bit ^ p);
    if (bit) {
      basis.push_back(bit);
      return update = true;
    } else
      return false;
  }
  bool check(ll bit) {
    for (auto &p : basis) bit = min(bit, bit ^ p);
    return bit == 0;
  }
  void normalize() {
    if (update) {
      sort(begin(basis), end(basis));
      update = false;
    }
    for (int i = (int)basis.size() - 1; i >= 0; i--) {
      for (int j = i - 1; j >= 0; j--)
        basis[i] = min(basis[i], basis[i] ^ basis[j]);
    }
  }
  bool operator==(BinaryBasis &a) {
    normalize(), a.normalize();
    return basis == a.basis;
  }
  ll get_kth(ll k) {
    if ((1ll << basis.size() <= k)) return -1;
    ll ret = 0;
    if (update) {
      sort(begin(basis), end(basis));
      update = false;
    }
    for (int i = (int)basis.size() - 1; i >= 0; i--) {
      if (k < (1ll << i))
        ret = min(ret, ret ^ basis[i]);
      else {
        k -= 1ll << i;
        ret = max(ret, ret ^ basis[i]);
      }
    }
    return ret;
  }
  size_t size() const { return basis.size(); }
};
signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int x = 0;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    x ^= a[i];
  }
  if (x == 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> s(n + 1);
  s[0] = 0;
  for (int i = 0; i < (n); i++) s[i + 1] = s[i] ^ a[i];
  vector<int> basis;
  int p = 0;
  for (int i = 0; i < (n); i++) {
    int e = s[i + 1] ^ s[p];
    for (auto &b : basis) chmin(e, e ^ b);
    if (e != 0) {
      p = i + 1;
      basis.push_back(e);
    }
  }
  cout << basis.size() << endl;
  return 0;
}
