#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int a[300300];
int s[300300];
int o[300300];
int rg[300300];
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    long long x;
    cin >> x;
    a[i] = __builtin_popcountll(x);
    s[i] = s[i - 1] + a[i];
    o[i] = o[i - 1] + (s[i] % 2);
  }
  stack<int> st;
  for (int i = n; i >= 1; --i) {
    while (st.size() > 0 && a[st.top()] <= a[i]) {
      st.pop();
    }
    if (st.size() > 0)
      rg[i] = st.top();
    else
      rg[i] = n + 1;
    st.push(i);
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int x = i; x <= n; x = rg[x]) {
      int l = x, r = rg[x] - 1, j = x - 1;
      while (l <= r) {
        int mid = (l + r) >> 1;
        if (s[mid] - s[i - 1] < a[x] * 2) {
          j = mid, l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      int cnt = o[rg[x] - 1] - o[j];
      if (s[i - 1] % 2 == 0) cnt = rg[x] - 1 - j - cnt;
      ans += cnt;
    }
  }
  cout << ans << endl;
}
