#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10, mod = 998244353;
int n, m, k, t, a[maxn];
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    for (j = 63; j >= 0; j--) {
      if (x >> j & 1) a[i]++;
    }
  }
  long long zero = 1, one = 0;
  long long ret = 0, now = 0;
  for (i = 1; i <= n; i++) {
    if (a[i] & 1) now ^= 1;
    if (now)
      ret += one++;
    else
      ret += zero++;
  }
  for (i = 1; i <= n; i++) {
    int mx = 0, sum = 0, zero = 0;
    for (j = i; j <= i + 65 && j <= n; j++) {
      mx = max(mx, a[j]);
      sum += a[j];
      if (a[j] & 1) zero ^= 1;
      if (!zero && mx > sum - mx) ret--;
    }
  }
  printf("%lld\n", ret);
  return 0;
}
