#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n;
int a[N], sum[N], b[65][N], cnt[65];
long long ans;
int t[2];
long long find(int l, int r, int lim) {
  int i, j;
  long long ret = 0;
  if (l > r) return 0;
  j = l - 1;
  t[0] = t[1] = 0;
  for (i = l; i <= r; ++i) {
    while (sum[i] - sum[j] >= lim) {
      ++t[sum[j] & 1];
      ++j;
    }
    ret += (long long)t[sum[i] & 1];
  }
  return ret;
}
void dfs(int l, int r, int mx) {
  if (r - l - 1 < 1) return;
  if (!mx) return;
  int i, tmx = 0;
  cnt[mx] = 1;
  b[mx][cnt[mx]] = l;
  for (i = l + 1; i <= r - 1; ++i)
    if (a[i] == mx) b[mx][++cnt[mx]] = i;
  b[mx][++cnt[mx]] = r;
  if (cnt[mx] > 2) {
    ans += find(l + 1, r - 1, mx + mx);
    for (i = 1; i <= cnt[mx] - 1; ++i) {
      ans -= find(b[mx][i] + 1, b[mx][i + 1] - 1, mx + mx);
    }
  }
  for (i = 1; i <= cnt[mx] - 1; ++i) dfs(b[mx][i], b[mx][i + 1], mx - 1);
}
int main() {
  int i, mx = 0;
  long long x;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%lld", &x);
    for (; x; x >>= 1)
      if (x & 1ll) ++a[i];
    mx = max(mx, a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  dfs(0, n + 1, mx);
  printf("%lld\n", ans);
  return 0;
}
