#include <bits/stdc++.h>
using namespace std;
vector<long long int> a(300100);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n;
  cin >> n;
  vector<long long int> b(n + 1);
  for (long long int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for (long long int i = 1; i <= n; i++) {
    bitset<64> temp;
    temp = b[i];
    long long int t1 = 0;
    for (long long int j = 0; j < 64; j++) {
      if (temp[j]) {
        t1++;
      }
    }
    a[i] = t1;
  }
  deque<long long int> even, odd;
  vector<long long int> pre;
  pre = a;
  for (long long int i = 1; i <= n; i++) {
    pre[i] += pre[i - 1];
  }
  vector<vector<long long int>> dp(n + 1, vector<long long int>(65, 0));
  for (long long int i = 0; i <= n; i++) {
    dp[i][0] = a[i];
    for (long long int j = i + 1; j <= min(64 + i, n); j++) {
      dp[i][j - i] = a[j];
      dp[i][j - i] = max(dp[i][j - i], dp[i][j - i - 1]);
    }
  }
  even.push_front(0);
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    if (pre[i] % 2 == 0) {
      long long int j = 0;
      for (j = 0; j < even.size(); j++) {
        if (i - even[j] - 1 > 64) {
          break;
        }
        long long int t1 = pre[i] - pre[even[j]];
        long long int mx = dp[even[j] + 1][i - even[j] - 1];
        if (t1 >= 2 * mx) {
          ans++;
        }
      }
      ans += even.size() - j;
      even.push_front(i);
    } else {
      long long int j = 0;
      for (j = 0; j < odd.size(); j++) {
        if (i - odd[j] - 1 > 64) {
          break;
        }
        long long int t1 = pre[i] - pre[odd[j]];
        long long int mx = dp[odd[j] + 1][i - odd[j] - 1];
        if (t1 >= 2 * mx) {
          ans++;
        }
      }
      ans += odd.size() - j;
      odd.push_front(i);
    }
  }
  cout << ans << endl;
}
