#include <bits/stdc++.h>   using namespace std;   const int maxn = 4e5 + 123;   long long n, m, k;   int num[maxn];   int dp[maxn][5];   int presum[maxn];   int tmp[maxn];   int main(int argc, char const *argv[]) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     std::cin >> n;     for (int i = 1; i <= n; i++) {       long long u;       std::cin >> u;       int one = 0;       while (u) {         if (u % 2 == 1) {           one++;         }         u /= 2;       }       num[i] = one;     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       dp[i][1] = dp[i - 1][1];       dp[i][0] = dp[i - 1][0];       presum[i] = presum[i - 1] + num[i];       if (presum[i] % 2 == 1) {         dp[i][1] += 1;       } else {         dp[i][0] += 1;       }     }     int cur = n + 1;     for (int i = n; i >= 0; --i) {       tmp[i] = cur;       if (num[i] != 0) {         cur = i;       }     }     for (int i = 1; i <= n; i++) {       int k = presum[i - 1] % 2;       int cur = i;       int sum = num[i];       int maxx = num[i];       for (int j = 1; j < 71; j++) {         int kk = tmp[cur];         if (maxx <= sum / 2) {           ans += dp[kk - 1][k] - dp[cur - 1][k];         }         maxx = max(maxx, num[kk]);         sum += num[kk];         cur = kk;         if (cur > n) {           break;         }       }       ans += dp[n][k] - dp[cur - 1][k];     }     std::cout << ans <<   n ;     return 0;   }   