#include <bits/stdc++.h>
using namespace std ;
const int N=200006;
int a[N],n,l[N];
long long ans = 0 ;
inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
int main(){
    n=read();
    int left=0;
    for(int i=1;i<=n;i++){
        a[i]=read();
        l[i]=left;
        if(a[i])left=i;
    }
    for(int i=1;i<=n;i++){
        int now=a[i];
        int j;
        for(j=l[i];j;j=l[j]){
            if(now&a[j])
                break;
            now^=a[j];
        }
        ans+=(long long)(i-j);
    }
    cout << ans << endl ;
}