#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
int N, M, K;
int A[MAXN];
long long P, H;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> P;
    A[i] = A[i - 1] + __builtin_popcountll(P);
    M = 0;
    for (int j = i - 1; j >= 0; j--) {
      if (A[i] - A[j] >= 118) {
        break;
      }
      M = max(M, A[j + 1] - A[j]);
      if ((A[i] - A[j]) & 1) {
        continue;
      }
      if (A[i] - A[j] < 2 * M) {
        H--;
      }
    }
    if (A[i] & 1) {
      H += K;
      K++;
    } else {
      H += i - K;
    }
  }
  cout << H << '\n';
  return 0;
}
