#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 101;
long long n, a[N], s[N];
long long b[301];
bool work(long long x) {
  for (long long i = 30; i >= 0; i--) {
    if ((x >> i) & 1) {
      if (!b[i]) {
        b[i] = x;
        return 1;
      }
      x ^= b[i];
    }
  }
  return 0;
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i <= n; i++) s[i] = s[i - 1] ^ a[i];
  if (s[n] == 0) {
    puts("-1");
    return 0;
  }
  long long ans = 0;
  for (long long i = n; i >= 1; i--)
    if (work(a[i])) ++ans;
  printf("%lld\n", ans);
}
