#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 100;
int a[maxn];
long long dp[maxn][2];
int get1(long long n) {
  int sum = 0;
  while (n != 0) {
    if ((n & 1) == 1) sum += 1;
    n >>= 1;
  }
  return sum;
}
int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    long long x;
    cin >> x;
    a[i] = get1(x);
  }
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[1][0] = 0;
  dp[1][1] = 0;
  for (int i = 2; i <= N; i++) {
    if (a[i] & 1) {
      dp[i][0] = dp[i - 1][1] + (a[i - 1] & 1);
      dp[i][1] = dp[i - 1][0] + !(a[i - 1] & 1);
    } else {
      dp[i][0] = dp[i - 1][0] + !(a[i - 1] & 1);
      dp[i][1] = dp[i - 1][1] + (a[i - 1] & 1);
    }
  }
  long long ans = 0;
  for (int i = 2; i <= N; i++) {
    int L = max(1, i - 120);
    int sum = a[i];
    int pmax = a[i];
    int res = 0;
    for (int j = i - 1; j >= L; j--) {
      pmax = max(pmax, a[j]);
      sum += a[j];
      if (sum & 1) continue;
      if (pmax > sum / 2) res += 1;
    }
    ans += dp[i][0] - res;
  }
  cout << ans << endl;
  return 0;
}
