#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 300005;
int n;
int a[N];
void solv() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    long long x;
    scanf("%lld", &x);
    while (x) {
      if (x % 2 == 1) ++a[i];
      x /= 2;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int s = 0;
    int maxu = 0;
    for (int j = i; j <= n; ++j) {
      s += a[i];
      maxu = max(maxu, a[i]);
      if (s - maxu >= maxu) ++ans;
    }
  }
  printf("%d\n", ans);
}
int main() {
  solv();
  return 0;
}
