#include <bits/stdc++.h> using namespace std; #define fru(j,n) for(int j=0; j<(n); ++j) #define tr(it,v) for(auto it=(v).begin(); it!=(v).end(); ++it) #define x first #define y second #define pb push_back #define mp make_pair #define ALL(G) (G).begin(),(G).end() typedef long long ll; typedef double D; typedef pair<int,int> pii; typedef vector<int> vi; const int inft = 1000000009; const int MAXN = 1000006; int a[MAXN]; map<ll,vector<ll> > M1,M2; map<ll,ll> H1,H2; void solve() { int n; scanf("%d",&n); fru(i,n)scanf("%d",a+i); // vector<pii> H1,H2; int n1=n/2,n2=n-n1; //first half for(int mask=1<<(n1-1);mask<(1<<n1);mask++){ ll first=-1,prev=-1,xo=0; for(int j=n1-1;j>=0;j--){ if(mask&(1<<j)){ if(prev!=-1)xo^=prev; if(first==-1 && prev!=-1)first=prev; prev=a[j]; }else{ prev+=a[j]; } } if(prev!=-1)xo^=prev; if(first==-1 && prev!=-1)first=prev; // H1.pb(pii(xo,first)); // printf("dodaje %lld %lld\n",xo,first); M1[first].pb(xo^first); H1[xo]++; } //second half for(int mask=1;mask<(1<<(n2));mask+=2){ ll first=-1,prev=-1,xo=0; for(int j=0;j<n2;j++){ if(mask&(1<<j)){ // printf("mam mas %d ->%d\n",mask,j); if(prev!=-1)xo^=prev; if(first==-1 && prev!=-1)first=prev; prev=a[n1+j]; }else{ prev+=a[n1+j]; } } if(prev!=-1)xo^=prev; if(first==-1 && prev!=-1)first=prev; // printf("dodaje %lld %lld\n",xo,first); //H2.pb(pii(xo,first)); M2[first].pb(xo^first); H2[xo]++; } // puts("H1"); // tr(it,H1)printf("(%d,%d) ",it->x,it->y);puts(""); // puts("H2"); // tr(it,H2)printf("(%d,%d) ",it->x,it->y);puts(""); long long ans=0; //without inner merge for(auto w1=H1.begin(),w2=H2.begin();w1!=H1.end() && w2!=H2.end();){ if(w1->x==w2->x){ ans+=1LL*w1->y*w2->y; w1++;w2++; } else if(w1->x<w2->x)w1++; else w2++; } // printf("teraz %lld\n",ans); //merge tr(it,M1)sort(ALL(it->y)); tr(it,M2)sort(ALL(it->y)); tr(it1,M1)tr(it2,M2){ // printf("mam val %lld, %lld\n",it1->x,it2->x); ll xo=it1->x+it2->x; tr(it,it1->y){ ll xo2=xo^*it; //szukam tego w drugim if(lower_bound(ALL(it2->y),xo2)==it2->y.end())continue; // printf("szukam %lld\n",xo2); ans+=upper_bound(ALL(it2->y),xo2)-lower_bound(ALL(it2->y),xo2); } } cout<<ans<<endl; } int main() { // freopen("input.in", "r", stdin); // freopen("output.out", "w", stdout); int t=1; // scanf("%d",&t); fru(i,t) solve(); return 0; }