#include <bits/stdc++.h>
using namespace std;
long long a[300050], cnt[300050];
void read(long long &rem) {
  rem = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') rem = rem * 10 + c - 48, c = getchar();
}
inline long long push(long long x) {
  long long ans = 0;
  for (int i = 0; (1ll << i) <= x; i++) ans += (x >> i) & 1;
  return ans;
}
int main() {
  long long output = 0, s = 0, d = 0;
  long long n;
  read(n);
  for (int i = 1; i <= n; i++) {
    long long x;
    read(x);
    a[i] = push(x);
    long long ls = s, ld = d;
    if (a[i] & 1)
      cnt[i] = ld, d = ls + 1, s = ld;
    else
      cnt[i] += s, s++;
  }
  for (int i = 2; i <= n; i++) {
    output += cnt[i];
    long long k = a[i], ans = a[i];
    for (int j = i - 1; j >= max(1, i - 70); j--) {
      k = max(k, a[j]);
      ans += a[j];
      if ((!(ans & 1)) && k * 2 > ans) output--;
    }
  }
  printf("%I64d", output);
}
