#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, w = 0;
  char ch = getchar();
  while (!isdigit(ch)) w |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  return w ? -x : x;
}
long long a[300003], b[300003], sum[300003], ans;
inline long long getfirst(long long k) {
  long long res = 0;
  for (; k; k &= k - 1) ++res;
  return res;
}
signed main() {
  long long n = read();
  b[0] = 1;
  for (long long i = 1; i <= n; i++)
    a[i] = getfirst(read()), sum[i] = sum[i - 1] + a[i];
  for (long long i = 1; i <= n; i++) {
    ans += b[sum[i] & 1], b[sum[i] & 1]++;
    ans -= ((sum[i] & 1) == (sum[i - 1] & 1));
  }
  for (long long i = 1; i <= n; i++) {
    long long now = a[i];
    for (long long j = i - 1; j >= max(1ll, i - 64); j--) {
      now = max(now, a[j]);
      long long opt = sum[i] - sum[j - 1];
      if (!(opt & 1) && now > opt - now) ans--;
    }
  }
  return printf("%lld\n", ans), 0;
}
