#include <bits/stdc++.h>
using namespace std;
long long a[300010], pre[300010];
int n, b[300010], pre0[300010], pre1[300010];
int main() {
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    b[i] = __builtin_popcountll(a[i]);
    pre[i] = pre[i - 1] + b[i];
    pre0[i] = pre0[i - 1] + (pre[i] & 1 ^ 1);
    pre1[i] = pre1[i - 1] + (pre[i] & 1);
  }
  for (int i = 1; i <= n; ++i) {
    if (pre[i - 1] & 1)
      ans += pre1[n] - pre1[i];
    else
      ans += pre0[n] - pre0[i];
    int range = min(i + 64, n), maxn = b[i];
    for (int j = i + 1; j <= range; ++j) {
      maxn = max(maxn, b[j]);
      if ((maxn << 1) <= pre[j] - pre[i - 1]) continue;
      if (pre[j] - pre[i - 1] & 1) continue;
      --ans;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
