#include <bits/stdc++.h>
const int N = 3e5 + 5;
using namespace std;
int n, a[N], cnt[N];
long long ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  ans = 1LL * n * (n + 1) / 2;
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    a[i] = __builtin_popcountll(x);
  }
  for (int i = n; i >= 1; i--) {
    a[i] += a[i + 1];
    cnt[i] = cnt[i + 1] + (a[i] & 1);
  }
  for (int i = 1; i <= n; i++) a[i] -= a[i + 1];
  for (int i = 1; i <= n; i++) {
    int j, sum, Max = -1;
    for (j = i, sum = a[i]; sum <= 120 && j <= n; j++, sum += a[j]) {
      Max = max(Max, a[j]);
      if (Max * 2 > sum || (sum & 1)) ans--;
    }
    if (cnt[i] == cnt[i + 1])
      ans -= cnt[j + 1];
    else
      ans -= (n - j + 1 - cnt[j + 1]);
  }
  cout << ans;
}
