#include <bits/stdc++.h>
using namespace std;
int a[300003];
int fsum[300003];
int cmax[300003][20];
int ceven[300003][2];
int pow2[20];
int CB(long long n) { return n ? CB(n & (n - 1)) + 1 : 0; }
int GetMax(int from, int to) {
  int pos = from, res = 0;
  for (int k = 20 - 1; k >= 0; k--) {
    if (pow2[k] + pos - 1 <= to) {
      res = max(res, cmax[pos][k]);
      pos += pow2[k];
    }
  }
  return res;
}
int GetSum(int from, int to) { return fsum[to + 1] - fsum[from]; }
bool IsEven(int from, int to) { return (GetSum(from, to) & 1) == 0; }
bool IsGood(int from, int to) {
  return IsEven(from, to) && GetMax(from, to) * 2 <= GetSum(from, to);
}
int Count(int to, bool isEven) {
  return ceven[to][isEven];
  int res = 0;
  for (int i = 0; i < to; i++) {
    if (IsEven(0, i) == isEven) {
      res++;
    }
  }
  return res;
}
int Calc(int to, bool isEven) {
  bool isEven2 = IsEven(0, to);
  if (isEven && isEven2) {
    return Count(to, true) + 1;
  }
  if (isEven && !isEven2) {
    return Count(to, false);
  }
  if (!isEven && isEven2) {
    return Count(to, false);
  }
  if (!isEven && !isEven2) {
    return Count(to, true) + 1;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    long long N;
    scanf("%I64d", &N);
    a[i] = CB(N);
  }
  fsum[0] = 0;
  for (int i = 0; i < n; i++) {
    fsum[i + 1] = fsum[i] + a[i];
  }
  pow2[0] = 1;
  for (int i = 1; i < 20; i++) pow2[i] = pow2[i - 1] * 2;
  for (int i = 0; i < n; i++) {
    cmax[i][0] = a[i];
  }
  for (int k = 1; k < 20; k++) {
    for (int i = 0; i < n; i++) {
      cmax[i][k] = cmax[i][k - 1];
      if (i + pow2[k - 1] < n) {
        cmax[i][k] = max(cmax[i][k - 1], cmax[i + pow2[k - 1]][k - 1]);
      }
    }
  }
  ceven[0][0] = ceven[0][1] = 0;
  for (int i = 0; i < n; i++) {
    ceven[i + 1][0] = ceven[i][0] + (IsEven(0, i) == false);
    ceven[i + 1][1] = ceven[i][1] + (IsEven(0, i) == true);
  }
  long long res = 0;
  const int lim = 64;
  for (int to = 0; to < n; to++) {
    for (int j = 0; j <= lim; j++) {
      int from = to - j;
      if (from >= 0 && from <= to) {
        res += IsGood(from, to);
      } else {
        break;
      }
    }
    int from = to - lim - 1;
    if (from >= 0) {
      res += Calc(from, IsEven(from + 1, to));
    }
  }
  cout << res << endl;
}
