#include <bits/stdc++.h>
const int MAXN = 3e5 + 19, MAXB = 61;
int n, a[MAXN], s[MAXN], x[MAXN];
int stack[MAXN], top;
long long ans;
int tr[MAXN];
void update(int x, int k) {
  for (; x <= n; x += x & -x) tr[x] += k;
}
int query(int x) {
  int res = 0;
  for (; x; x -= x & -x) res += tr[x];
  return res;
}
int tag;
int query(int l, int r) {
  int g = query(r) - query(l - 1);
  if (!tag) g = (r - l + 1) - g;
  return g;
}
long long cacl(int l, int r, int n) {
  if (s[n] - s[r - 1] >= 2 * a[r]) return query(l, r);
  if (s[n] - s[l - 1] < 2 * a[r]) return 0;
  int L = l, R = r - 1;
  while (L < R) {
    int mid = (L + R + 1) >> 1;
    if (s[n] - s[mid - 1] >= 2 * a[r])
      L = mid;
    else
      R = mid - 1;
  }
  return query(l, L);
}
int main() {
  std::scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    long long tmp;
    std::scanf("%lld", &tmp);
    for (int j = 0; j <= 60; ++j)
      if (tmp & (1ll << j)) ++a[i];
    s[i] = s[i - 1] + a[i];
    x[i] = x[i - 1] ^ (a[i] & 1);
    update(i + 1, x[i]);
  }
  for (int i = 1; i <= n; ++i) {
    while (top && a[stack[top]] <= a[i]) --top;
    stack[++top] = i;
    tag = x[i];
    for (int j = 1; j <= top; ++j) ans += cacl(stack[j - 1] + 1, stack[j], i);
  }
  std::printf("%lld\n", ans);
  return 0;
}
