#include <bits/stdc++.h>
using namespace std;
int n;
int a[300010];
long long an = 0;
int popcount(long long x) {
  int res = 0;
  for (int i = 0; i < 61; i++) {
    if (x & (1ll << i)) res++;
  }
  return res;
}
const int maxn = 300010;
int pref_mx[maxn];
int pref_sum[maxn];
int odd[maxn], even[maxn];
int suf_mx[maxn];
int suf_sum[maxn];
void go(int vl, int vr) {
  if (vl == vr) {
    return;
  }
  int vm = (vl + vr) >> 1;
  go(vl, vm);
  go(vm + 1, vr);
  int old = an;
  int cursum = 0, curmx = 0;
  int curodd = 0, cureven = 0;
  for (int i = vm + 1; i <= vr; i++) {
    cursum += a[i];
    curmx = max(curmx, a[i]);
    if (cursum & 1)
      curodd++;
    else
      cureven++;
    pref_mx[i] = curmx;
    pref_sum[i] = cursum;
    odd[i] = curodd;
    even[i] = cureven;
  }
  cursum = 0, curmx = 0;
  for (int i = vm; i >= vl; i--) {
    cursum += a[i];
    curmx = max(curmx, a[i]);
    int lo = vm, hi = vr;
    while (lo != hi) {
      int mi = (lo + hi + 1) >> 1;
      if (pref_mx[mi] > curmx)
        hi = mi - 1;
      else
        lo = mi;
    }
    if (lo == vm) continue;
    int rg = hi;
    int need_sum = curmx * 2 - cursum;
    lo = vm + 1, hi = rg + 1;
    while (lo != hi) {
      int mi = (lo + hi) >> 1;
      if (pref_sum[mi] < need_sum)
        lo = mi + 1;
      else
        hi = mi;
    }
    if (lo == rg + 1) continue;
    int lg = lo;
    if (cursum & 1) {
      an += odd[rg];
      if (lg > vm + 1) an -= odd[lg - 1];
    } else {
      an += even[rg];
      if (lg > vm + 1) an -= even[lg - 1];
    }
  }
  cursum = 0, curmx = 0;
  curodd = 0, cureven = 0;
  for (int i = vm; i >= vl; i--) {
    cursum += a[i];
    curmx = max(curmx, a[i]);
    if (cursum & 1)
      curodd++;
    else
      cureven++;
    suf_mx[i] = curmx;
    suf_sum[i] = cursum;
    odd[i] = curodd;
    even[i] = cureven;
  }
  cursum = 0, curmx = 0;
  for (int i = vm + 1; i <= vr; i++) {
    cursum += a[i];
    curmx = max(curmx, a[i]);
    int lo = vl, hi = vm + 1;
    while (lo != hi) {
      int mi = (lo + hi) >> 1;
      if (suf_mx[mi] >= curmx)
        lo = mi + 1;
      else
        hi = mi;
    }
    if (lo == vm + 1) continue;
    int lg = lo;
    int need = curmx * 2 - cursum;
    lo = vl - 1, hi = vm;
    while (lo != hi) {
      int mi = (lo + hi + 1) >> 1;
      if (suf_sum[mi] < need)
        hi = mi - 1;
      else
        lo = mi;
    }
    if (hi == vl - 1) continue;
    int rg = hi;
    if (cursum & 1) {
      an += odd[lg];
      if (rg < vm) an -= odd[rg + 1];
    } else {
      an += even[lg];
      if (rg < vm) an -= even[rg + 1];
    }
  }
}
int stupid() {
  int res = 0;
  for (int l = 0; l < n; l++) {
    int curmx = 0, cursum = 0;
    for (int r = l; r < n; r++) {
      curmx = max(curmx, a[r]);
      cursum += a[r];
      if (2 * curmx - cursum <= 0 && cursum % 2 == 0) {
        res++;
        cout << l << ' ' << r << endl;
      }
    }
  }
  return res;
}
mt19937 mt(123);
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a[i] = popcount(x);
  }
  go(0, n - 1);
  cout << an << '\n';
  return 0;
}
