#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, vector<T> a) {
  os << "( ";
  for (T& first : a) os << first << " ";
  os << ")\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> a) {
  os << "( ";
  for (T first : a) os << first << " ";
  os << ")\n";
  return os;
}
template <typename X, typename Y>
ostream& operator<<(ostream& os, pair<X, Y> a) {
  os << "(" << a.first << " " << a.second << ") ";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, complex<T> a) {
  os << "(r=" << a.real() << " i=" << a.imag() << ") ";
  return os;
}
template <typename X, typename Y>
pair<X, Y>& operator-=(pair<X, Y>& A, pair<X, Y> B) {
  A.first -= B.first;
  A.second -= B.second;
  return A;
}
template <typename X, typename Y>
pair<X, Y>& operator+=(pair<X, Y>& A, pair<X, Y> B) {
  A.first += B.first;
  A.second += B.second;
  return A;
}
template <typename X, typename Y, typename Z>
pair<X, Y>& operator*=(pair<X, Y>& A, Z n) {
  A.first *= n;
  A.second *= n;
  return A;
}
template <typename X, typename Y>
Y operator*(pair<X, Y> A, pair<X, Y> B) {
  return A.first * B.first + A.second * B.second;
}
template <typename X, typename Y>
Y operator^(pair<X, Y> A, pair<X, Y> B) {
  return A.first * B.second - A.second * B.first;
}
template <typename X, typename Y>
X operator^(X a, Y b) {
  return a ^= b;
}
template <typename X, typename Y>
X operator+(X a, Y b) {
  return a += b;
}
template <typename X, typename Y>
X operator-(X a, Y b) {
  return a -= b;
}
template <typename X, typename Y>
X operator*(X a, Y b) {
  return a *= b;
}
template <typename X, typename Y>
X operator/(X a, Y b) {
  return a /= b;
}
const int base = 1000000007;
long long power(long long a, long long n, long long mod = base) {
  a = a < 0 ? (mod - (-a) % mod) : (a % mod);
  long long r = 1;
  while (n) {
    if (n & 1) r = r * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return r;
}
const int nmax = 200022;
bitset<nmax> a[30];
int main(int argc, char** argv) {
  if (argc > 2) {
    freopen(argv[1], "r", stdin);
    freopen(argv[2], "w", stdout);
  }
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int first;
    cin >> first;
    s ^= first;
    for (int j = 30; j--;)
      if (first >> j & 1) {
        a[j].set(i);
      }
  }
  if (s == 0) {
    cout << -1;
    return 0;
  }
  int ans = 0;
  for (int i = 0, j = 0; i < 30 && j < n; ++i, ++j) {
    for (int k = i; k < 30; ++k)
      if (a[k][j]) {
        swap(a[i], a[k]);
        break;
      }
    if (!a[i][j]) {
      --i;
      continue;
    }
    for (int k = i + 1; k < 30; ++k)
      if (a[k][j]) {
        a[k] ^= a[i];
      }
    ++ans;
  }
  cout << ans;
  if (0)
    cout << "time"
         << " = " << ((long long)(clock() * 1000 / CLOCKS_PER_SEC)) << endl;
}
