#include <iostream>
#include <vector>
using namespace std;

int n,a[200010];
     
int main() {
    cin>>n;
    int i,j;
    for (i=1;i<=n;i++)cin>>a[i];
    int sum=0,left=1;
    long long ans=0;
    for (i=1;i<=n;i++) {
        while (sum&a[i]) {
          	ans+=i-left;
          	sum-=a[left];
          	left++;
        }
       	sum|=a[i];
    }
    while (left<=n){
    	ans+=n-left;
    	left++;
	}
    cout<<ans<<endl;
    return 0;
}