#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int Maxn = 200005;

ll n, j;
ll a[Maxn];
ll sum, h;
int main() {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	for(int i = 0; i < n; ++i) {
		for(j; j < n; ++j) {
			if((h|a[j]) != h + a[j]) break;
			else h += a[j], sum += j - i + 1;
		}
		h -= a[i];
	}
	printf("%d", sum);
	return 0;
}