#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
char buf[1 << 21], *p1 = buf, *p2 = buf;
inline long long read() {
  long long x = 0, f = 1;
  char c =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
           ? EOF
           : *p1++);
  for (; !isdigit(c);
       c = (p1 == p2 &&
                    (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
                ? EOF
                : *p1++))
    if (c == '-') f = -1;
  for (; isdigit(c);
       c = (p1 == p2 &&
                    (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
                ? EOF
                : *p1++))
    x = (x + (x << 2) << 1) + c - 48;
  return x * f;
}
int a[N], s[N], s1, s2, n;
long long ans;
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    long long x = read();
    while (x) a[i] += x & 1, x >>= 1;
    s[i] = s[i - 1] + a[i];
  }
  for (int i = 1; i <= n; ++i)
    if (s[i] & 1)
      ans += ++s1;
    else
      ans += ++s2;
  ans -= s2;
  for (int i = 1, mx; i <= n; ++i) {
    mx = a[i];
    for (int j = i + 1; j <= min(i + 60, n); ++j) {
      mx = max(mx, a[j]);
      if ((s[j] - s[i - 1]) % 2 == 0 && mx > (s[j] - s[i - 1]) / 2) --ans;
    }
  }
  return !printf("%lld", ans);
}
