#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  int n;
  cin >> n;
  for (int ni = 0; ni < n; ni++) {
    cin >> a[ni];
  }
  int left = 0;
  int right = 1;
  int cur = a[0];
  long long answer = 0;
  while (left < n) {
    while (right < n) {
      if ((cur & a[right]) > 0) break;
      cur |= a[right];
      right++;
    }
    answer += right - left;
    cur ^= a[left];
    left++;
  }
  cout << answer << endl;
  return 0;
}
