#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int nBits(long long x) {
  int res = 0;
  while (x) {
    res += x & 1;
    x >>= 1;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  vector<int> bits(n);
  vector<long long> sum(2);
  long long res = 0;
  int m = 0, pi = -1;
  for (int i = 0; i < n; ++i) {
    long long c;
    cin >> c;
    bits[i] = nBits(c);
    if (bits[i] & 1) {
      int cl = i - pi;
      sum[m & 1] += cl;
      res -= cl;
      ++m;
      pi = i;
    }
  }
  int cl = n - pi;
  sum[m & 1] += cl;
  res -= cl;
  res += sum[0] * sum[0] + sum[1] * sum[1];
  res /= 2;
  for (int i = 0; i < n; ++i) {
    int cm = 0;
    int cs = 0;
    for (int j = i; j < min(n, i + 64); ++j) {
      cm = max(cm, bits[j]);
      cs += bits[j];
      if (!(cs & 1) && 2 * cm > cs) {
        --res;
      }
    }
  }
  cout << res;
  return 0;
}
