#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long ret = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  do {
    ret = ret * 10 + c - '0';
    c = getchar();
  } while ('0' <= c && c <= '9');
  return ret;
}
int n;
long long a[300100];
long long dp[2][300100], ans;
int main() {
  long long tmp1;
  int tmp2;
  n = read();
  for (int i = 1; i <= n; i++) {
    tmp1 = read();
    tmp2 = 0;
    while (tmp1) {
      tmp2 += (tmp1 & 1);
      tmp1 >>= 1;
    }
    a[i] = tmp2;
  }
  long long fsum, fmax, add;
  for (int i = 1; i <= n; i++) {
    fsum = fmax = add = 0;
    for (int j = i; j >= 1 && i - j < 64; j--) {
      fsum += a[j];
      fmax = max(fmax, a[j]);
      if (fmax > fsum - fmax && fsum % 2 == 0) add--;
    }
    if (a[i] & 1) {
      dp[0][i] = dp[1][i - 1];
      dp[1][i] = dp[0][i - 1] + 1;
    } else {
      dp[0][i] = dp[0][i - 1] + 1;
      dp[1][i] = dp[1][i - 1];
    }
    add += dp[0][i];
    ans += add;
  }
  printf("%I64d\n", ans);
  return 0;
}
