#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 300000;
int n;
long long a[MAXN];
int cnt[MAXN];
int sum[MAXN + 1];
long long solve() {
  for (int i = (0); i < (n); ++i) {
    cnt[i] = 0;
    for (long long x = a[i]; x != 0; x /= 2) cnt[i] += x & 1;
  }
  sum[0] = 0;
  for (int i = (0); i < (n); ++i) sum[i + 1] = sum[i] + cnt[i];
  int gmx = 0;
  for (int i = (0); i < (n); ++i) gmx = max(gmx, cnt[i]);
  long long even = 0, odd = 0, ret = 0;
  for (int i = (0); i <= (n); ++i) {
    if (sum[i] % 2 == 0) {
      ret += even;
      ++even;
    } else {
      ret += odd;
      ++odd;
    }
    for (int j = i - 1, cmx = 0; j >= 0 && sum[i] - sum[j] <= 2 * gmx; --j) {
      cmx = max(cmx, cnt[j]);
      if ((sum[i] - sum[j]) % 2 == 0 && 2 * cmx > sum[i] - sum[j]) --ret;
    }
  }
  return ret;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%lld", &a[i]);
  printf("%lld\n", solve());
}
int main() {
  run();
  return 0;
}
