#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int maxm = 3e5 * 64 + 10;
const long long mod = 1e9 + 7;
const int inf = (int)1e9 + 50;
const double eps = 1e-5;
const double pi = acos(-1.0);
long long n;
int b[maxn];
int sum[maxn];
int c0[maxm], c1[maxm];
long long ans;
void update0(int x, int v) {
  for (int i = x; i <= maxm; i += (i) & (-i)) c0[i] += v;
}
int getsum0(int x) {
  int sum = 0;
  for (int i = x; i > 0; i -= (i) & (-i)) sum += c0[i];
  return sum;
}
void update1(int x, int v) {
  for (int i = x; i < maxm; i += (i) & (-i)) c1[i] += v;
}
int getsum1(int x) {
  int sum = 0;
  for (int i = x; i > 0; i -= (i) & (-i)) sum += c1[i];
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long t;
    cin >> t;
    int cnt = 0;
    for (long long j = 0; j <= 62; j++)
      if (t & (1LL << j)) cnt++;
    b[i] = cnt;
    sum[i] += (sum[i - 1] + b[i]);
  }
  for (int i = 1; i <= n; i++) {
    long long t;
    if (sum[i] & 1) {
      if (sum[i] >= 2 * b[i]) {
        t = getsum1(sum[i] - 2 * b[i]);
        ans += t;
      }
      update1(sum[i], 1);
    } else {
      if (sum[i] >= 2 * b[i]) {
        t = getsum0(sum[i] - 2 * b[i]);
        ans += t;
        ans++;
      }
      update0(sum[i], 1);
    }
  }
  cout << ans;
  return ~~(0 - 0);
}
