#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
const long long infl = 2e18;
const long long infi = 2e9;
const long long mod = 1e9 + 7;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk = clock();
long long rng(long long lim) {
  uniform_int_distribution<long long> uid(0, lim);
  return uid(rang);
}
long long a[200005];
vector<long long> ld, ld2, res;
vector<pair<long long, long long> > segs, segs2;
vector<long long> reduce(vector<long long> ld) {
  ld.clear();
  return ld2;
}
bool check(long long i) {
  long long te = (1 << 30) - 1 - i;
  for (long long ii : ld) {
    if (te < (ii ^ te)) {
      te ^= ii;
    }
  }
  if (te + 1 == (1 << 30)) return 0;
  return 1;
}
void solve() {
  long long n;
  cin >> n;
  long long xorian = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    xorian ^= a[i];
  }
  if (xorian == 0) {
    cout << -1 << '\n';
    return;
  }
  segs.push_back({1, n});
  ld.push_back(xorian);
  bool notdone = 1;
  while (notdone) {
    notdone = 0;
    for (long long ii = 0; ii < segs.size(); ii++) {
      auto &temp = segs[ii];
      long long xo = 0;
      for (long long i = temp.first; i < temp.second && (!notdone); i++) {
        xo ^= a[i];
        if (check(xo)) {
          ld.push_back(xo);
          for (long long j = 29; j >= 0; j--) {
            for (long long i : ld) {
              if (i & (1 << j)) {
                ld2.push_back(i);
                for (long long &k : ld) {
                  if (k & (1 << j)) k ^= i;
                }
                break;
              }
            }
          }
          ld2.swap(ld);
          ld2.clear();
          for (long long j = 0; j < ii; j++) segs2.push_back(segs[j]);
          segs2.push_back({temp.first, i});
          segs2.push_back({i + 1, temp.second});
          for (long long j = ii + 1; j < segs.size(); j++)
            segs2.push_back(segs[j]);
          segs.swap(segs2);
          segs2.clear();
          notdone = 1;
        }
      }
      if (notdone) break;
    }
  }
  cout << ld.size() << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  long long t = 1;
  while (t--) solve();
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

You are given an array a_1, a_2, ..., a_n of integer numbers.

Your task is to divide the array into the maximum number of segments in such a way that:

  * each element is contained in exactly one segment; 
  * each segment contains at least one element; 
  * there doesn't exist a non-empty subset of segments such that bitwise XOR of the numbers from them is equal to 0. 



Print the maximum number of segments the array can be divided into. Print -1 if no suitable division exists.

Input

The first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the size of the array.

The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9).

Output

Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.

Examples

Input


4
5 5 7 2


Output


2


Input


3
1 2 3


Output


-1


Input


3
3 1 10


Output


3

Note

In the first example 2 is the maximum number. If you divide the array into \{[5], [5, 7, 2]\}, the XOR value of the subset of only the second segment is 5 ⊕ 7 ⊕ 2 = 0. \{[5, 5], [7, 2]\} has the value of the subset of only the first segment being 5 ⊕ 5 = 0. However, \{[5, 5, 7], [2]\} will lead to subsets \{[5, 5, 7]\} of XOR 7, \{[2]\} of XOR 2 and \{[5, 5, 7], [2]\} of XOR 5 ⊕ 5 ⊕ 7 ⊕ 2 = 5.

Let's take a look at some division on 3 segments — \{[5], [5, 7], [2]\}. It will produce subsets:

  * \{[5]\}, XOR 5; 
  * \{[5, 7]\}, XOR 2; 
  * \{[5], [5, 7]\}, XOR 7; 
  * \{[2]\}, XOR 2; 
  * \{[5], [2]\}, XOR 7; 
  * \{[5, 7], [2]\}, XOR 0; 
  * \{[5], [5, 7], [2]\}, XOR 5; 



As you can see, subset \{[5, 7], [2]\} has its XOR equal to 0, which is unacceptable. You can check that for other divisions of size 3 or 4, non-empty subset with 0 XOR always exists.

The second example has no suitable divisions.

The third example array can be divided into \{[3], [1], [10]\}. No subset of these segments has its XOR equal to 0.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
const long long infl = 2e18;
const long long infi = 2e9;
const long long mod = 1e9 + 7;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk = clock();
long long rng(long long lim) {
  uniform_int_distribution<long long> uid(0, lim);
  return uid(rang);
}
long long a[200005];
vector<long long> ld, ld2, res;
vector<pair<long long, long long> > segs, segs2;
vector<long long> reduce(vector<long long> ld) {
  ld.clear();
  return ld2;
}
bool check(long long i) {
  long long te = (1 << 30) - 1 - i;
  for (long long ii : ld) {
    if (te < (ii ^ te)) {
      te ^= ii;
    }
  }
  if (te + 1 == (1 << 30)) return 0;
  return 1;
}
void solve() {
  long long n;
  cin >> n;
  long long xorian = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    xorian ^= a[i];
  }
  if (xorian == 0) {
    cout << -1 << '\n';
    return;
  }
  segs.push_back({1, n});
  ld.push_back(xorian);
  bool notdone = 1;
  while (notdone) {
    notdone = 0;
    for (long long ii = 0; ii < segs.size(); ii++) {
      auto &temp = segs[ii];
      long long xo = 0;
      for (long long i = temp.first; i < temp.second && (!notdone); i++) {
        xo ^= a[i];
        if (check(xo)) {
          ld.push_back(xo);
          for (long long j = 29; j >= 0; j--) {
            for (long long i : ld) {
              if (i & (1 << j)) {
                ld2.push_back(i);
                for (long long &k : ld) {
                  if (k & (1 << j)) k ^= i;
                }
                break;
              }
            }
          }
          ld2.swap(ld);
          ld2.clear();
          for (long long j = 0; j < ii; j++) segs2.push_back(segs[j]);
          segs2.push_back({temp.first, i});
          segs2.push_back({i + 1, temp.second});
          for (long long j = ii + 1; j < segs.size(); j++)
            segs2.push_back(segs[j]);
          segs.swap(segs2);
          segs2.clear();
          notdone = 1;
        }
      }
      if (notdone) break;
    }
  }
  cout << ld.size() << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  long long t = 1;
  while (t--) solve();
  return 0;
}

```