#include <bits/stdc++.h>
using namespace std;
int F[200005][19], Log[200005], sum[200005][31], U[105];
int n, k, now, i, m, r;
long long ans;
void buildST() {
  for (int k = 1; k <= 18; k++)
    for (int i = 1; i <= n && i + (1 << k) - 1 <= n; i++)
      F[i][k] = max(F[i][k - 1], F[i + (1 << (k - 1))][k - 1]);
}
int Max(int l, int r) {
  int t = Log[r - l + 1];
  return max(F[l][t], F[r - (1 << t) + 1][t]);
}
int solve(int l1, int l2, int Xor, int R) {
  int l = l1, r = l2 + 1;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (mid == l2 + 1 || Max(mid, R) < Xor)
      r = mid;
    else
      l = mid + 1;
  }
  return l2 - l + 1;
}
int main() {
  scanf("%d", &n);
  for (i = 0; i <= 18; i++) Log[1 << i] = i;
  for (i = 2; i <= n; i++)
    if (!Log[i]) Log[i] = Log[i - 1];
  for (i = 1; i <= n; i++) {
    scanf("%d", &F[i][0]);
    memcpy(sum[i], sum[i - 1], sizeof(sum[i - 1]));
    for (k = 0; k <= 29; k++)
      if ((F[i][0] >> k) & 1) sum[i][k] = i;
  }
  buildST();
  for (r = 1; r <= n; r++) {
    m = 0;
    for (k = 0; k <= 29; k++)
      if (sum[r][k]) U[++m] = sum[r][k];
    U[++m] = r;
    sort(U + 1, U + m + 1);
    m = unique(U + 1, U + m + 1) - (U + 1);
    now = 0;
    for (i = m; i; i--) {
      now |= F[U[i]][0];
      ans += solve(U[i - 1] + 1, U[i], now, r);
    }
  }
  printf("%I64d\n", ans);
}
