#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void Cin(T &x) {
  register char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  for (x = 0; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
}
const int maxN = 3e5 + 2, maxVal = 119;
static int nexta[maxN], cnt[maxN][2], a[maxN], s[maxN], n;
long long x, ans = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Cin(n);
  for (int i = 1; i <= n; ++i)
    Cin(x), s[i] = s[i - 1] + (a[i] = __builtin_popcountll(x));
  a[n + 1] = maxVal;
  s[n + 1] = s[n] + a[n + 1];
  for (int i = n; i > 0; --i) {
    for (nexta[i] = i + 1; a[nexta[i]] <= a[i]; nexta[i] = nexta[nexta[i]])
      ;
    cnt[i][0] = cnt[i + 1][0];
    cnt[i][1] = cnt[i + 1][1];
    ++cnt[i][s[i] & 1];
  }
  for (int l = 0; l < n; ++l) {
    for (int MaxPos = l + 1, r = l + 1, sl = s[l]; MaxPos <= n;) {
      int lim = nexta[MaxPos], bound = sl + (a[MaxPos] << 1);
      for (r = max(MaxPos, r); r < lim && s[r] < bound; ++r)
        ;
      if (r < lim) ans += cnt[r][sl & 1] - cnt[lim][sl & 1];
      MaxPos = lim;
    }
  }
  cout << ans;
  return 0;
}
