#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
long long n;
long long vals[MAXN];
long long pref[MAXN];
long long cnt1[MAXN];
long long pr[MAXN];
inline void init() {}
inline void solve() {
  init();
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> vals[i];
    vals[i] = __builtin_popcountll(vals[i]);
  }
  for (long long i = 0; i < n; i++) {
    pref[i] = (i == 0 ? 0ll : pref[i - 1]) + vals[i];
    if (pref[i] % 2 == 0) {
      cnt1[i] = 1;
    } else {
      cnt1[i] = 0;
    }
  }
  for (long long i = n - 1; i >= 0; i--) {
    pr[i] = (i == n - 1 ? 0ll : pr[i + 1]) + cnt1[i];
  }
  for (long long i = 0; i < n; i++) {
    long long mx = 0;
    long long sum = 0;
    for (long long j = i; j < min(i + 500, n); j++) {
      sum += vals[j];
      mx = max(mx, vals[j]);
      if (sum % 2 == 0 && mx * 2 > sum) {
        ans--;
      }
    }
    long long all_even = pr[i];
    if (i == 0 || pref[i - 1] % 2 == 0) {
      ans += all_even;
    } else {
      ans += n - i - all_even;
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  while (cin >> n) solve();
  return 0;
}
