#include <bits/stdc++.h>
const int N = 1e6 + 10;
using std::lower_bound;
using std::upper_bound;
void file(const char *str) {
  char in[100], out[100];
  sprintf(in, "%s.in", str), sprintf(out, "%s.out", str);
  freopen(in, "r", stdin), freopen(out, "w", stdout);
}
const int _IB = 1e6;
char _ibuf[_IB], *_s, *_t;
long long read() {
  long long a = 0;
  int op = 1;
  char ch =
      (_s == _t && (_t = (_s = _ibuf) + fread(_ibuf, 1, _IB, stdin), _s == _t)
           ? EOF
           : *_s++);
  while (ch < '0' || '9' < ch) {
    if (ch == '-') op = -1;
    ch =
        (_s == _t && (_t = (_s = _ibuf) + fread(_ibuf, 1, _IB, stdin), _s == _t)
             ? EOF
             : *_s++);
  }
  while ('0' <= ch && ch <= '9') {
    a = (a << 3) + (a << 1) + (48 ^ ch);
    ch =
        (_s == _t && (_t = (_s = _ibuf) + fread(_ibuf, 1, _IB, stdin), _s == _t)
             ? EOF
             : *_s++);
  }
  return a * op;
}
long long a[N];
long long sum[N];
long long ct[2][N];
int n;
namespace ST {
int son[N][2];
int pos[N];
int root;
int node_count;
int check(int x, int y) { return a[x] > a[y] ? x : y; }
int build(int l = 1, int r = n) {
  int t = node_count++;
  if (l != r) {
    int mm = l + (r - l) / 2;
    son[t][0] = build(l, mm);
    son[t][1] = build(mm + 1, r);
    pos[t] = check(pos[son[t][0]], pos[son[t][1]]);
  } else {
    pos[t] = l;
  }
  return t;
}
int get(int l, int r, int t = root, int L = 1, int R = n) {
  if (l == L && r == R) return pos[t];
  int mm = L + (R - L) / 2;
  if (r <= mm)
    return get(l, r, son[t][0], L, mm);
  else if (l > mm)
    return get(l, r, son[t][1], mm + 1, R);
  else
    return check(get(l, mm, son[t][0], L, mm),
                 get(mm + 1, r, son[t][1], mm + 1, R));
}
}  // namespace ST
long long bitct(long long x) {
  long long ret = 0;
  while (x) {
    ret += x & 1;
    x >>= 1;
  }
  return ret;
}
void input() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = bitct(read());
}
long long getByLeft(int l, int r, int p) {
  long long ret = 0;
  for (int i = l, j; i <= p; i++) {
    j = lower_bound(sum + p, sum + r + 1, sum[i - 1] + 2 * a[p]) - sum;
    ret += ct[sum[i - 1] & 1][r] - ct[sum[i - 1] & 1][j - 1];
  }
  return ret;
}
long long getByRight(int l, int r, int p) {
  long long ret = 0;
  for (int i = r, j; i >= p; i--) {
    j = upper_bound(sum + l - 1, sum + p, sum[i] - 2 * a[p]) - sum;
    ret += ct[sum[i] & 1][j - 1];
    if (l > 1) ret -= ct[sum[i] & 1][l - 2];
  }
  return ret;
}
long long getans(int l, int r) {
  if (l >= r) return 0;
  int p = ST::get(l, r);
  long long ret = 0;
  ret += getans(l, p - 1);
  ret += getans(p + 1, r);
  int mm = l + (r - l) / 2;
  if (p <= mm)
    ret += getByLeft(l, r, p);
  else
    ret += getByRight(l, r, p);
  return ret;
}
void ini() {}
void solve() {
  ST::root = ST::build();
  ct[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i];
    ct[sum[i] & 1][i]++;
    ct[0][i] += ct[0][i - 1];
    ct[1][i] += ct[1][i - 1];
  }
}
void output() { printf("%lld\n", getans(1, n)); }
void test() {
  input();
  ini();
  solve();
  output();
}
void all() {
  file("F");
  test();
}
int main() {
  test();
  return 0;
}
