#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
using namespace std;
vector<int> base;
int main() {
  int n, a, t = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    t ^= a;
    int now = t;
    for (int b : base)
      if ((now ^ b) < now) now ^= b;
    if (now) base.push_back(now);
  }
  if (t)
    printf("%d\n", base.size());
  else
    puts("-1");
  return 0;
}
