#include <bits/stdc++.h>
using namespace std;
long long inline read() {
  long long num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
const long long maxn = 300010, mod = 998244353;
long long n, a[maxn], b[maxn], t[2], ans, c[maxn];
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= n; i++) {
    long long x = a[i], ans = 0;
    while (x) {
      x -= x & (-x);
      ans++;
    }
    c[i] = b[i] = ans;
  }
  for (long long i = 1; i <= n; i++) b[i] += b[i - 1];
  t[b[0]]++;
  for (long long i = 1; i <= n; i++) {
    ans += t[b[i] & 1];
    t[b[i] & 1]++;
  }
  for (long long i = 1; i <= n; i++) {
    long long mx = 0;
    for (long long j = i; j >= 1 && i - j <= 70; j--) {
      mx = max(mx, c[j]);
      if (((b[i] - b[j - 1]) & 1) == 0 && b[i] - b[j - 1] - mx < mx) ans--;
    }
  }
  cout << ans;
  return 0;
}
