#include <bits/stdc++.h>
using namespace std;
int n, a[300010], sum[300010], mx[300010];
long long ans = 0;
void work(int l, int r) {
  if (l == r) {
    ans += (!a[l]);
    return;
  }
  int mid = (l + r) >> 1, j, k, _0, _1;
  work(l, mid);
  work(mid + 1, r);
  sum[mid] = mx[mid] = a[mid];
  sum[mid + 1] = mx[mid + 1] = a[mid + 1];
  for (int i = mid - 1; i >= l; i--)
    sum[i] = sum[i + 1] + a[i], mx[i] = max(mx[i + 1], a[i]);
  for (int i = mid + 2; i <= r; i++)
    sum[i] = sum[i - 1] + a[i], mx[i] = max(mx[i - 1], a[i]);
  _0 = _1 = 0;
  j = k = mid;
  for (int i = mid; i >= l; i--) {
    while (mx[k + 1] <= mx[i] && k + 1 <= r) k++, (sum[k] & 1) ? ++_1 : ++_0;
    while (sum[j + 1] + sum[i] < 2 * mx[i] && j < k)
      j++, (sum[j] & 1) ? --_1 : --_0;
    while (sum[j] + sum[i] >= 2 * mx[i] && j > mid)
      (sum[j] & 1) ? ++_1 : ++_0, j--;
    ans += (sum[i] & 1) ? _1 : _0;
  }
  _0 = _1 = 0;
  j = k = mid + 1;
  for (int i = mid + 1; i <= r; i++) {
    while (mx[k - 1] < mx[i] && k - 1 >= l) k--, (sum[k] & 1) ? ++_1 : ++_0;
    while (sum[j - 1] + sum[i] < 2 * mx[i] && j > k)
      j--, (sum[j] & 1) ? --_1 : --_0;
    while (sum[j] + sum[i] >= 2 * mx[i] && j <= mid)
      (sum[j] & 1) ? ++_1 : ++_0, j++;
    ans += (sum[i] & 1) ? _1 : _0;
  }
}
int main() {
  scanf("%d", &n);
  long long w;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &w);
    while (w) a[i] += (w & 1), w >>= 1;
  }
  work(1, n);
  printf("%lld\n", ans);
}
