#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long maxn = 2e5 + 20;
const long long inf = (long long)2e9;
const long double pi = 3.14159265358979323846264;
const long double eps = 1e-8;
const long long mod = (long long)1e9 + 7;
const long long ns = 97;
random_device rd;
mt19937 SuperRandom(rd());
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n;
  cin >> n;
  vector<long long> goo(n);
  for (auto& x : goo) cin >> x;
  long long ans = 0;
  long long s0 = 1, s1 = 0, s = 0;
  vector<long long> kek(n);
  for (long long i = 0; i < n; ++i) {
    long long x = goo[i];
    long long t = __builtin_popcount(x);
    s += t;
    if (s % 2) {
      ans += s1;
      ++s1;
    } else {
      ans += s0;
      ++s0;
    }
    kek[i] = s;
    long long mx = t;
    for (long long j = i - 1; j >= max(0ll, i - 61); --j) {
      long long _s = s;
      if (j > 0) _s = s - kek[j - 1];
      mx = max(mx, (long long)__builtin_popcount(goo[j]));
      if (2 * mx > _s) --ans;
    }
  }
  cout << ans;
}
