#include <bits/stdc++.h>
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end() {}
int n;
long long ans;
long long a[N];
long long s[2][N], sum[N];
int d[N][20];
void initrmq() {
  for (int i = 1; i <= n; ++i) d[i][0] = a[i];
  for (int j = 1; (1 << j) <= n; ++j)
    for (int i = 1; i + (1 << (j - 1)) <= n; ++i)
      d[i][j] = max(d[i][j - 1], d[i + (1 << (j - 1))][j - 1]);
}
int querymax(int l, int r) {
  int k = log2(r - l + 1);
  return max(d[l][k], d[r - (1 << k) + 1][k]);
}
void solve130() {
  for (int len = 1; len <= min(n, 129); ++len)
    for (int i = 1; i + len - 1 <= n; ++i) {
      int mx = querymax(i, i + len - 1);
      if (mx * 2 <= sum[i + len - 1] - sum[i - 1] &&
          (sum[i + len - 1] - sum[i - 1]) % 2 == 0)
        ans++;
    }
}
inline void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    a[i] = __builtin_popcountll(a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  initrmq();
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 2; ++j) s[j][i] = s[j][i - 1];
    s[sum[i] & 1][i]++;
  }
  if (n <= 129) {
    solve130();
    cout << ans << endl;
    return;
  }
  solve130();
  for (int i = 1; i + 129 <= n; ++i) {
    int p = (sum[i + 128] - sum[i - 1]) % 2;
    int p2 = sum[i - 1] % 2;
    int r = i + 129;
    if ((p2 % 2 == 0 && p % 2) || (p2 % 2 == 0 && p % 2 == 0)) {
      ans += s[0][n] - s[0][r - 1];
    } else {
      ans += s[1][n] - s[1][r - 1];
    }
  }
  cout << ans << endl;
}
int main() {
  TIME__START = clock();
  int Test = 1;
  while (Test--) {
    solve();
  }
  TIME__END = clock();
  program_end();
  return 0;
}
