#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000")
#pragma GCC target(arch = corie7 - acx)
#pragma GCC optimize(2)
using namespace std;
long long n, s1, s0, a[3000002], x, ans, s[3000002], sum;
long long lowbit(long long x) { return x & (-x); }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &x);
    for (; x; x -= lowbit(x)) a[i]++;
  }
  for (long long i = n; i >= 1; i--) {
    s[i] = s[i + 1] + a[i];
    if (s[i] & 1)
      ans += s1++;
    else
      ans += ++s0;
    x = sum = 0;
    for (long long j = i; j <= min(n, i + 61); j++) {
      x = max(x, a[j]);
      sum += a[j];
      if (sum % 2 == 0 && x > sum / 2) ans--;
    }
  }
  printf("%lld", ans);
  return 0;
}
