#include <bits/stdc++.h>
using namespace std;
long long seg[1 << 20];
long long ans;
long long get_or(long long l, long long r) {
  long long res = 0;
  l += 1 << 19, r += 1 << 19;
  while (l < r) {
    if (l % 2) res |= seg[l++];
    if (r % 2) res |= seg[--r];
    l /= 2;
    r /= 2;
  }
  return res;
}
long long a[220000];
set<pair<long long, pair<long long, long long> > > ban;
long long before[220000];
map<long long, long long> last;
int main() {
  long long n;
  cin >> n;
  long long ans = n * (n - 1) / 2;
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    seg[(1 << 19) + i] = a[i];
    if (last.count(a[i]) == 0)
      before[i] = 0;
    else
      before[i] = last[a[i]] + 1;
    last[a[i]] = i;
  }
  for (long long i = (1 << 19) - 1; i > 0; i--)
    seg[i] = seg[i * 2] | seg[i * 2 + 1];
  for (long long i = 0; i < n; i++) {
    long long bottom = before[i], top = i;
    if (get_or(bottom, i + 1) == a[i]) top = bottom;
    while (top - bottom > 1) {
      long long mid = (top + bottom) / 2;
      if (get_or(mid, i + 1) == a[i])
        top = mid;
      else
        bottom = mid;
    }
    long long l = top;
    bottom = i, top = n - 1;
    if (get_or(i, n) == a[i]) bottom = n - 1;
    while (top - bottom > 1) {
      long long mid = (top + bottom) / 2;
      if (get_or(i, mid + 1) == a[i])
        bottom = mid;
      else
        top = mid;
    }
    long long r = bottom;
    ans -= (i - l + 1) * (r - i + 1) - 1;
  }
  printf("%lld\n", ans);
  return 0;
}
