#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cstdlib>
#include<iomanip>
#include<cmath>
#include<cassert>
#include<ctime>
#include<map>
#include<set>
using namespace std;

#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 0x3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int ans[26],n,a[200006];
ll pos=0,cnt=0;

int main()
{
	cin>>n;
	int k=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		int flag=1;
		for(int j=0;j<=20;j++)
		{
			if(a[i]&(1<<j))
			{
				ans[j]++;
			}
			if(ans[j]>1)
			{
				flag=0;
			}
		}
		
		if(!flag)
        {
            pos+=cnt;
            while(k<i)
            {
                int ok=1;
                for(int j=0;j<=20;j++)
                {
                    ans[j]-=(a[k]&(1<<j))?1:0;
                    if(ans[j]>1)
					{
						ok=0;
					}
                }
                k++;
                cnt--;
                if(ok)
				{
					break;
				}
                else
				{
					pos+=cnt;
				}
            }
        }
        cnt++;
	}
	cout<<(long long)pos+((1+cnt)*cnt/2);
	return 0;
}
