#include <bits/stdc++.h>
using namespace std;
short ONE_OR_ZERO[200005][25] = {0};
int t[25];
int a[200005];
long long n, s, tot = 0;
bool flag;
void TWO(int num, int x) {
  for (int tot = 1; tot <= 25; tot++) {
    ONE_OR_ZERO[num][tot] = ONE_OR_ZERO[num - 1][tot];
  }
  int tot = 0;
  while (x > 0) {
    tot++;
    ONE_OR_ZERO[num][tot] = ONE_OR_ZERO[num - 1][tot] + x % 2;
    x = x >> 1;
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    TWO(i, a[i]);
  }
  for (int l = 1; l <= n - 1; l++) {
    for (int r = l + 1; r <= n; r++) {
      flag = 0;
      for (int i = 1; i <= 25; i++) {
        t[i] = ONE_OR_ZERO[r][i] - ONE_OR_ZERO[l - 1][i];
        if (t[i] == 0 || t[i] == 1) {
          flag = flag;
        } else {
          flag = 1;
        }
      }
      if (!flag) {
        tot++;
      }
    }
  }
  printf("%d", tot + n);
  return 0;
}
