#include <list> #include <map> #include <set> #include <deque> #include <stack> #include <queue> #include <algorithm> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <memory.h> #include <ctime> #include <bitset> #include <unordered_map> using namespace std; #define ABS(a) ((a>0)?a:-(a)) #define MIN(a,b) ((a<b)?(a):(b)) #define MAX(a,b) ((a<b)?(b):(a)) #define FOR(i,a,n) for (int i=(a);i<(n);++i) #define FI(i,n) for (int i=0; i<(n); ++i) #define pnt pair <int, int> #define mp make_pair #define PI 3.1415926535897 #define MEMS(a,b) memset(a,b,sizeof(a)) #define LL long long #define U unsigned int a[40]; vector<pair<LL, LL> > gen(vector<int> a) { vector<pair<LL, LL> > res; int len = a.size(); if (len == 0) return res; FOR(mask, 0, (1 << (len - 1))) { LL x = 0; LL s = a[0]; FOR(i, 0, len - 1) { if ((mask >> i) & 1) { s += a[i + 1]; } else { x ^= s; s = a[i + 1]; } } res.push_back(mp(s, x)); } return res; } vector<int> p1; vector<int> p2; vector<pair<LL, LL> > c, b; unordered_map<LL, int> mm1; unordered_map<LL, int> mm2[18]; LL val[18]; int main() { #ifdef Fcdkbear freopen("in.txt", "r", stdin); double beg = clock(); //freopen("out.txt", "w", stdout); #endif int n; scanf("%d", &n); FOR(i, 0, n) scanf("%d", &a[i]); int m1 = n / 2; int m2 = n - m1; FOR(i, 0, m1) { p1.push_back(a[i]); } FOR(i, m1, n) { p2.push_back(a[i]); } reverse(p2.begin(), p2.end()); b = gen(p1); c = gen(p2); FOR(i, 0, c.size()) mm1[c[i].first^c[i].second]++; sort(c.begin(), c.end()); LL res = 0; FOR(i, 0, b.size()) res += mm1[b[i].first^b[i].second]; int cnt = 0; FOR(i, 0, c.size()) { if ((i == 0) || (c[i].first != c[i - 1].first)) { cnt++; val[cnt - 1] = c[i].first; } mm2[cnt - 1][c[i].second]++; } FOR(i, 0, b.size()) { FOR(j, 0, cnt) { LL have = b[i].second ^ (b[i].first + val[j]); res += mm2[j][have]; } } cout << res << endl; #ifdef Fcdkbear double end = clock(); fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC); #endif return 0; }