#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define SZ(x) ((int)(x).size())
#define PB(x) push_back(x)
#define MEMSET(x,v) memset(x,v,sizeof(x))
#define REP(i,n) for(int i=0;(i)<(n);++(i))
#define x first
#define y second
#define INF (0x3f3f3f3f)

typedef long long LL;
typedef pair<int, int> P2;
typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> OST;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
template<class A, class B> inline bool mina(A &x, B y) {return (x > y)?(x=y,1):0;}
template<class A, class B> inline bool maxa(A &x, B y) {return (x < y)?(x=y,1):0;}

const int MAXN = 3e5+5;

int N;
int in[MAXN];
int psum[MAXN];

LL solve(vector<P2> &x) {
    // cout << "==============" << endl;
    // for (P2 p : x) {
    //     cout << p.x << " ";
    // }
    // cout << endl;
    // for (P2 p : x) {
    //     cout << p.y << " ";
    // }
    // cout << endl;
    for (int i = 1; i < SZ(x); i++) {
        maxa(x[i].y, x[i - 1].y);
    }
    set<P2> S;
    for (int i = 1; i < SZ(x); i++) {
        S.insert(P2(x[i].x - x[i].y, i));
    }
    LL ret = 0;
    REP(i, SZ(x) - 1) {
        while (!S.empty() && S.begin()->x < x[i].x) {
            S.erase(S.begin());
        }
        ret += SZ(S);
    }
    return ret;
}

int main() {
    scanf("%d", &N);
    REP(i, N) {
        LL x;
        scanf("%lld", &x);
        while (x) {
            in[i + 1] += (x & 1);
            x >>= 1;
        }
    }

    for (int i = 1; i <= N; i++) {
        psum[i] = psum[i - 1] + in[i];
    }
    vector<P2> odds;
    vector<P2> evens;
    REP(i, N + 1) {
        if (psum[i] % 2) odds.PB(P2(psum[i], 2 * in[i]));
        else evens.PB(P2(psum[i], 2 * in[i]));
    }
    LL ans = 0;
    ans += solve(odds);
    ans += solve(evens);
    cout << ans << endl;
    return 0;
}
