#include <algorithm> #include <iostream> #include <sstream> #include <utility> #include <cstdlib> #include <cstring> #include <cassert> #include <fstream> #include <cstdio> #include <string> #include <vector> #include <queue> #include <cmath> #include <ctime> #include <stack> #include <map> #include <set> using namespace std; #define pb push_back #define ppb pop_back #define mp make_pair #define fs first #define sc second #define abs(a) ((a) < 0 ? -(a) : (a)) #define sqr(a) ((a) * (a)) typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; const double eps = 1e-9; const int mod = (int)1e+9 + 7; const double pi = acos(-1.); const int maxn = 50; int a[maxn]; map<int, int> ans[maxn]; vector<pair<int, int> > nxt; int main() { #ifdef SOL { // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); } #else { srand(time(0)); const string file = ""; if(!file.empty()) { freopen((file + ".in").c_str(), "r", stdin); freopen((file + ".out").c_str(), "w", stdout); } } #endif int n; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", &a[i]); } int hf = n - n / 2; for(int i = 0; i < (1 << hf); i++) { int xr = 0, stk = 0; for(int bt = 0; bt < hf - 1; bt++) { if(((i >> bt) & 1) == 1) { stk += a[bt]; } else { stk += a[bt]; xr ^= stk; stk = 0; } } int bt = hf - 1; if(((i >> bt) & 1) == 1) { stk += a[bt]; nxt.pb(mp(xr, stk)); } else { stk += a[bt]; xr ^= stk; stk = 0; ans[hf][xr]++; // cout << hf << " " << xr << endl; } } ll ret = 0; for(int i = hf; i < n; i++) { for(int f = 0; f < (int)nxt.size(); f++) { nxt[f].sc += a[i]; ans[i + 1][nxt[f].fs ^ nxt[f].sc]++; // cout << i + 1 << " " << (nxt[f].fs ^ nxt[f].sc) << endl; } for(int mask = 0; mask < (1 << (n - i)); mask++) { int xr = 0, stk = 0; for(int bt = 0; bt < n - i - 1; bt++) { if(((mask >> bt) & 1) == 1) { stk += a[i + bt]; } else { stk += a[i + bt]; xr ^= stk; stk = 0; } } int bt = n - i - 1; if(((mask >> bt) & 1) == 1) { stk += a[i + bt]; } else { stk += a[i + bt]; xr ^= stk; stk = 0; ret += ans[i][xr]; // cout << "-- " << i << " " << xr << endl; } } } ret += ans[n][0]; printf("%lld", ret); return(0); } // by Kim Andrey