#include <bits/stdc++.h>
using namespace std;
long long n = 0, ans = 0;
long long oddCnt = 0, evenCnt = 0;
long long s[300005] = {};
bool sumEven[300005] = {};
long long bitCnt(long long ori) {
  long long cnt = 0;
  while (ori) {
    cnt += ori & 1;
    ori >>= 1;
  }
  return cnt;
}
int main() {
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> s[i];
    s[i] = bitCnt(s[i]);
  }
  long long sum = 0;
  oddCnt = 0, evenCnt = 1, sumEven[n] = true;
  for (long long i = n - 1; i >= 0; --i) {
    sum += s[i];
    if (sum & 1) {
      ans += oddCnt;
      oddCnt++;
    } else {
      ans += evenCnt;
      sumEven[i] = true;
      evenCnt++;
    }
  }
  for (long long i = 0; i < n; ++i) {
    long long sumx = 0, maxi = 0;
    for (long long j = i; j < min(n, i + 64LL); ++j) {
      if (s[j] > maxi) {
        sumx += maxi;
        maxi = s[j];
      } else {
        sumx += s[j];
      }
      if (sumx < maxi && sumEven[i] == sumEven[j + 1]) {
        ans--;
      }
    }
  }
  cout << ans;
  return 0;
}
