#include <bits/stdc++.h>
using namespace std;
const int N = 300001;
long long dp[N], pre[N], a[N], cnt[N][2];
int main() {
  cnt[0][0] = 1;
  long long ans = 0;
  int n, o = 0, e = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    long long x;
    cin >> x;
    a[i] = __builtin_popcount(x);
    pre[i] = pre[i - 1] + a[i];
    cnt[i][0] = cnt[i - 1][0];
    cnt[i][1] = cnt[i - 1][1];
    if (pre[i] % 2 == 0)
      ++cnt[i][0];
    else
      ++cnt[i][1];
  }
  for (int i = 1; i <= n; ++i) {
    if (pre[i] % 2 == 0)
      dp[i] = cnt[i][0] - 1;
    else
      dp[i] = cnt[i][1] - 1;
    for (long long j = 0, m = 0; j <= 64; ++j) {
      if (i > j) {
        m = max(m, a[i - j]);
        int sum = pre[i] - pre[i - j - 1];
        if (sum % 2 == 0 && m > sum - m) --dp[i];
      } else
        break;
    }
    ans += dp[i];
  }
  cout << ans << "\n";
}
