#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#define ll long long
using namespace std;
const int maxn=200005;

int n,a[maxn],lef[maxn];
ll ans=0;

int main(){
	scanf("%d",&n);
	for(int i=1,las=0;i<=n;i++){
		scanf("%d",a+i),lef[i]=las;
		if(a[i]) las=i;
	}
	
	for(int i=1,now,j;i<=n;i++){
		now=a[i];
		
		for(j=lef[i];j;now^=a[j],j=lef[j]) if(now&a[j]) break;
		
		ans+=(ll)(i-j);
		
	}
	
	cout<<ans<<endl;
	return 0;
}