#include <bits/stdc++.h>
using namespace std;
const int M = 300005;
int n, A[M], mr[M], sum[M], odd[M];
int main() {
  long long x;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &x);
    A[i] = 0;
    while (x) {
      A[i] += x & 1;
      x >>= 1;
    }
    sum[i] = sum[i - 1] + A[i];
    odd[i] = odd[i - 1] + (sum[i] & 1);
  }
  for (int i = n; i >= 1; i--) {
    int now = i + 1;
    while (now <= n && A[i] >= A[now]) now = mr[now];
    mr[i] = now;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int mx = A[i];
    int L = i, R = mr[i];
    while (1) {
      int p = lower_bound(sum + L, sum + n + 1, sum[i - 1] + mx * 2) - sum;
      if (R > p) {
        if (sum[i - 1] & 1)
          ans += odd[R - 1] - odd[p - 1];
        else
          ans += R - p - (odd[R - 1] - odd[p - 1]);
      }
      if (R == n + 1) break;
      L = R, mx = A[L], R = mr[R];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
