#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (long long int t = a[i]; t; t &= t - 1) b[i]++;
  }
  long long ans = n * (n + 1ll) / 2;
  for (int i = 0; i < n; i++) {
    int odd[2] = {1};
    int l = i - 1;
    int sum = 0;
    while (l >= 0 && sum + b[l] < b[i]) sum += b[l--], odd[sum & 1]++;
    ans -= i - l - odd[1 - (b[i] & 1)];
    int sum2 = 0;
    for (int j = i + 1; j < n; j++) {
      sum2 += b[j];
      while (sum + sum2 >= b[i] && l < i - 1) {
        odd[sum & 1]--;
        sum -= b[++l];
      }
      if (sum + sum2 >= b[i])
        break;
      else
        ans -= i - l - odd[1 - ((b[i] ^ sum2) & 1)];
    }
  }
  int odd[2] = {1};
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum ^= b[i] & 1;
    ans -= odd[1 - sum];
    odd[sum]++;
  }
  cout << ans << '\n';
}
