#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N], prefmx[N], prefor[N], suffmx[N], suffor[N];
long long ans;
void rec(int l, int r) {
  if (l == r || l > r) return;
  int m = l + r >> 1;
  rec(l, m);
  rec(m + 1, r);
  prefmx[m + 1] = a[m + 1], prefor[m + 1] = a[m + 1];
  for (int i = m + 2; i <= r; ++i)
    prefmx[i] = max(prefmx[i - 1], a[i]), prefor[i] = (prefor[i - 1] | a[i]);
  suffmx[m] = suffor[m] = a[m];
  for (int i = m - 1; i >= l; --i)
    suffmx[i] = max(suffmx[i + 1], a[i]), suffor[i] = (suffor[i + 1] | a[i]);
  vector<int> v1, v2;
  for (int i = m; i >= l; --i) v2.emplace_back(suffmx[i]);
  for (int i = m + 1; i <= r; ++i) v1.emplace_back(prefmx[i]);
  for (int i = m + 1; i <= r; ++i) {
    if (prefmx[i] != prefor[i]) continue;
    auto to = upper_bound((v2).begin(), (v2).end(), prefmx[i]) - v2.begin();
    to--;
    int lf = 0, rg = to;
    int pos = -1;
    while (lf <= rg) {
      int mid = rg + lf >> 1;
      if ((suffor[m - mid] | prefor[i]) == prefmx[i])
        pos = mid, lf = mid + 1;
      else
        rg = mid - 1;
    }
    ans += (1 + pos);
  }
  for (int i = m; i >= l; --i) {
    if (suffmx[i] != suffor[i]) continue;
    auto to = lower_bound((v1).begin(), (v1).end(), suffmx[i]) - v1.begin();
    to--;
    int lf = 0, rg = to;
    int pos = -1;
    while (lf <= rg) {
      int mid = rg + lf >> 1;
      if ((prefor[m + 1 + mid] | suffor[i]) == suffmx[i])
        pos = mid, lf = mid + 1;
      else
        rg = mid - 1;
    }
    ans += (1 + pos);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  rec(1, n);
  ans += n;
  ans = ((n * 1ll * (n + 1)) / 2) - ans;
  printf("%lld\n", ans);
  return 0;
}
