#include <bits/stdc++.h>
using namespace std;
int b[300000], pre[300001];
int main() {
  int i;
  int n;
  long long int a;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &a);
    while (a > 0) b[i] += a & 1, a >>= 1;
    pre[i + 1] = pre[i] + b[i];
  }
  int j, k;
  long long int ans = 0;
  for (i = 0; i < 100; i++) {
    int num[2];
    num[0] = num[1] = 0;
    vector<pair<int, int> > v;
    int p = -1;
    for (j = 0; j < n; j++) {
      if (b[j] > i) {
        if (j - 1 >= p + 1) v.push_back(make_pair(p + 1, j - 1));
        p = j;
      }
    }
    if (j - 1 >= p + 1) v.push_back(make_pair(p + 1, j - 1));
    for (j = 0; j < v.size(); j++) {
      int l = v[j].first;
      int num[2];
      num[0] = num[1] = 0;
      for (k = v[j].first; k <= v[j].second; k++) {
        while (pre[k + 1] - pre[l] >= 2 * i) {
          num[pre[l] & 1]++;
          l++;
        }
        ans += num[pre[k + 1] & 1];
      }
    }
    v.clear();
    p = -1;
    for (j = 0; j < n; j++) {
      if (b[j] >= i) {
        if (j - 1 >= p + 1) v.push_back(make_pair(p + 1, j - 1));
        p = j;
      }
    }
    if (j - 1 >= p + 1) v.push_back(make_pair(p + 1, j - 1));
    for (j = 0; j < v.size(); j++) {
      int l = v[j].first;
      int num[2];
      num[0] = num[1] = 0;
      for (k = v[j].first; k <= v[j].second; k++) {
        while (pre[k + 1] - pre[l] >= 2 * i) {
          num[pre[l] & 1]++;
          l++;
        }
        ans -= num[pre[k + 1] & 1];
      }
    }
    v.clear();
  }
  printf("%I64d\n", ans);
  return 0;
}
