#include <bits/stdc++.h> using namespace std; #define fillchar(a, s) memset((a), (s), sizeof(a)) #define debug(...) fprintf(stderr, __VA_ARGS__) #define all(v) (v).begin(), (v).end() #define rep(it, v) for (auto it = (v).begin(); it != (v).end(); it++) typedef long long ll; typedef pair<int, int> pii; typedef unordered_map<ll, int> uset; const int MAXN = 36, MAXH = 18; int N, H; vector<ll> L, R; uset lset[MAXN], rset[MAXN]; void compute_sums (vector<ll> v, uset *arr) { arr[0][0]++; for (int i = 1; i <= v.size(); i++) { // cerr << "JINC " << i << endl; for (int j = 0; j < (1 << (i - 1)); j++) { // cerr << "j = " << j << endl; ll sx = 0; for (int k = 0; k < i; ) { ll cval = v[k]; int cur = k; while (true) { if (j & (1 << cur)) { cval += v[cur + 1]; cur++; } else { k = cur + 1; break; } } // cerr << "XOR\n"; sx ^= cval; } arr[i][sx]++; // cerr << "INSERT " << sx << endl; } } } int main() { if (fopen("input.txt", "r")) { freopen("input.txt", "r", stdin); } ios::sync_with_stdio(false); cin >> N; H = N / 2; for (int i = 0, x; i < N; i++) { cin >> x; if (i < H) { L.push_back(x); } else { R.push_back(x); } } compute_sums(L, lset); reverse(all(R)); compute_sums(R, rset); reverse(all(R)); reverse(rset, rset + R.size() + 1); //check if cross middle or doesn't cross middle ll ans = 0; ll lsum = 0; //cross for (int i = L.size() - 1; i >= 0; i--) { lsum += L[i]; ll sum = lsum; //left i to right j uset &stl = lset[i]; for (int j = 0; j < R.size(); j++) { sum += R[j]; //j + 1 rite? mhm rset[j + 1] uset &str = rset[j + 1]; for (auto it : stl) { ll want = it.first ^ sum; auto f = str.find(want); if (f != str.end()) { ans += ll(it.second) * f->second; // cerr << "i = " << i << " and j = " << j << ": ans += " << it.second << " * " << f->second << endl; // cerr << "TO THE SU " << sum << endl; } } } } //no cross uset &stl = lset[L.size()]; for (auto it : rset[0]) { auto f = stl.find(it.first); if (f != stl.end()) { ans += ll(it.second) * f->second; } } //output ans! cout << ans << endl; }