#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5;
long long a[N];
int32_t tree[N << 2], bit_cnt[N];
struct seg_tree {
  long long combine(long long x, long long y) { return max(x, y); }
  void build(long long l, long long r, long long node) {
    if (l == r) {
      tree[node] = bit_cnt[l];
      return;
    }
    long long mid = (l + r) >> 1, lc = node + node, rc = 1 + lc;
    build(l, mid, lc);
    build(mid + 1, r, rc);
    tree[node] = combine(tree[lc], tree[rc]);
  }
  long long query(long long l, long long r, long long ql, long long qr,
                  long long node) {
    if (qr < l || r < ql) return 0;
    if (ql <= l and r <= qr) {
      return tree[node];
    }
    long long mid = (l + r) >> 1, lc = node + node, rc = 1 + lc;
    return combine(query(l, mid, ql, qr, lc), query(mid + 1, r, ql, qr, rc));
  }
};
long long dp[N][2];
long long prefix_sum[N];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
    bit_cnt[i] = __builtin_popcountll(a[i]);
  }
  seg_tree ins;
  ins.build(1, n, 1);
  for (long long i = 1; i <= n; ++i) {
    prefix_sum[i] = bit_cnt[i] + prefix_sum[i - 1];
  }
  dp[0][0] = 1;
  map<long long, long long> mp;
  mp[0] = 1;
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    long long c = prefix_sum[i] & 1LL;
    dp[i][0] = dp[i - 1][0];
    dp[i][1] = dp[i - 1][1];
    dp[i][c] += 1;
    ans += dp[i - 1][c];
    long long res = -1, mx = bit_cnt[i];
    long long sum = 0;
    for (long long j = i; i - j <= 62 && j > 0; --j) {
      mx = max(mx, (long long)bit_cnt[j]);
      sum += bit_cnt[j];
      if ((sum - mx < mx) && (sum & 1) == 0) {
        --ans;
      }
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  for (long long i = 1; i <= t; ++i) {
    solve();
  }
  return 0;
}
