#include <bits/stdc++.h>
using namespace std;
int N, A[222222];
int nextNumber[222222][30];
map<int, set<int> > m;
int getNext(int start, int n) {
  set<int> &s = m[n];
  set<int>::iterator it = s.lower_bound(start);
  if (it == s.end()) return N;
  return *it;
}
int main(int argc, char *argv[]) {
  scanf("%d", &N);
  for (int i = 0; i < (N); i++) scanf("%d", A + i);
  for (int i = 0; i < (N); i++) m[A[i]].insert(i);
  for (int i = 0; i < (30); i++) nextNumber[N][i] = N;
  for (int i = (N - 1); i >= (0); i--) {
    for (int bit = 0; bit < (30); bit++) {
      if (A[i] & (1 << bit))
        nextNumber[i][bit] = i;
      else
        nextNumber[i][bit] = nextNumber[i + 1][bit];
    }
  }
  long long ans = 0;
  for (int start = 0; start < (N); start++) {
    set<int> candidates;
    candidates.insert(N);
    for (int bit = 0; bit < (30); bit++)
      candidates.insert(nextNumber[start][bit]);
    vector<int> c(candidates.begin(), candidates.end());
    int n = 0;
    for (int i = 0; i < (c.size() - 1); i++) {
      n |= A[c[i]];
      int tmp = min(c[i + 1], getNext(start, n)) - c[i];
      ans += tmp;
    }
  }
  cout << ans << endl;
  return 0;
}
