#include <bits/stdc++.h>
using namespace std;
long long ans, n, dp[300100][2], a[300100];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], a[i] = __builtin_popcountll(a[i]);
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] % 2 == 1) {
      dp[i][0] = dp[i + 1][1] + 1;
      dp[i][1] = dp[i + 1][0];
    } else {
      dp[i][0] = dp[i + 1][0];
      dp[i][1] = dp[i + 1][1] + 1;
    }
    long long sum = 0, mx = 0, add = 0;
    for (int j = i; j < min(n, i + 65ll); j++) {
      sum += a[j];
      mx = max(mx, a[j]);
      if (mx > sum - mx && sum % 2 == 0) add--;
    }
    ans += dp[i][1] + add;
  }
  cout << ans << endl;
  return 0;
}
