#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200005],n,ans,i,j,h;
int main() {
	scanf("%lld",&n);
	for (i=0; i<n; ++i)scanf("%lld",a+i);
	for (i=0; i<n; ++i) {
		for (j; j<n; ++j) {
			if((h|a[j])!=h+a[j])break;
			else h=h+a[j],ans=ans+j-i+1;
		}
		
		h-=a[i];
	}
	printf("%lld\n",ans);
	return 0;
}
//(A+B)-(A^B)=2(A&B)