 #include<iostream>
#include<queue>
#include<cstring>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<string>
using namespace std;
#define ll long long
#define se second
#define fi first
int n;
const int maxn = 300010;
long long arr[maxn];
int w[maxn];
int sum[maxn];
int dp[maxn][2];
int main()
{
    memset(w,0,sizeof(w));
    scanf("%d",&n);
    for(int i = 1 ; i <= n; ++i)
    {
        scanf("%lld",arr+i);
        long long k = 1;
        for(int j = 0; j < 62; ++j, k <<= 1)
        {
            if( k & arr[i] )
                w[i] ++;
        }
        //cout << w[i] << endl;
    }
    dp[1][0] = dp[1][1] = dp[0][0] = dp[0][1] = 0;
    for(int i = 2; i <= n; ++i)
    {
        //cout << w[i] << endl;
        if(w[i] % 2 == 1)
        {
            dp[i][0] = dp[i-1][1]+(w[i-1]%2);
            dp[i][1] = dp[i-1][0]+!(w[i-1]%2);
        }
        else
        {
            dp[i][0] = dp[i-1][0]+!(w[i-1]%2);
            dp[i][1] = dp[i-1][1]+(w[i-1]%2);
        }
    }
    ll ans = 0;
    for(int i = 2; i <= n; ++i)
    {
        int add = 0;
        int mx = w[i];
        int sum = w[i];
        for(int j = i-1; j >= 1 && i-j<=120; --j)
        {
            mx = max(mx,w[j]);
            sum += w[j];
            if(mx > sum - mx && sum % 2 == 0)
                add --;
        }
        //cout << dp[i][0] << endl;
        //cout << add << endl;
        add += dp[i][0];
        ans += add;
    }
    printf("%d\n",ans);
}


 #include<iostream>
#include<queue>
#include<cstring>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<string>
using namespace std;
#define ll long long
#define se second
#define fi first
int n;
const int maxn = 300010;
long long arr[maxn];
int w[maxn];
int sum[maxn];
int dp[maxn][2];
int main()
{
    memset(w,0,sizeof(w));
    scanf("%d",&n);
    for(int i = 1 ; i <= n; ++i)
    {
        scanf("%lld",arr+i);
        long long k = 1;
        for(int j = 0; j < 62; ++j, k <<= 1)
        {
            if( k & arr[i] )
                w[i] ++;
        }
        //cout << w[i] << endl;
    }
    dp[1][0] = dp[1][1] = dp[0][0] = dp[0][1] = 0;
    for(int i = 2; i <= n; ++i)
    {
        //cout << w[i] << endl;
        if(w[i] % 2 == 1)
        {
            dp[i][0] = dp[i-1][1]+(w[i-1]%2);
            dp[i][1] = dp[i-1][0]+!(w[i-1]%2);
        }
        else
        {
            dp[i][0] = dp[i-1][0]+!(w[i-1]%2);
            dp[i][1] = dp[i-1][1]+(w[i-1]%2);
        }
    }
    ll ans = 0;
    for(int i = 2; i <= n; ++i)
    {
        ll add = 0;
        ll mx = w[i];
        ll sum = w[i];
        for(int j = i-1; j >= 1 && i-j<=120; --j)
        {
            mx = max(mx,w[j]);
            sum += w[j];
            if(mx > sum - mx && sum % 2 == 0)
                add --;
        }
        //cout << dp[i][0] << endl;
        //cout << add << endl;
        add += dp[i][0];
        ans += add;
    }
    printf("%lld\n",ans);
}


 #include<iostream>
#include<queue>
#include<cstring>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<string>
using namespace std;
#define ll long long
#define se second
#define fi first
int n;
const int maxn = 300010;
long long arr[maxn];
int w[maxn];
int sum[maxn];
int dp[maxn][2];
int main()
{
    memset(w,0,sizeof(w));
    scanf("%d",&n);
    for(int i = 1 ; i <= n; ++i)
    {
        scanf("%lld",arr+i);
        long long k = 1;
        for(int j = 0; j < 62; ++j, k <<= 1)
        {
            if( k & arr[i] )
                w[i] ++;
        }
        //cout << w[i] << endl;
    }
    dp[1][0] = dp[1][1] = dp[0][0] = dp[0][1] = 0;
    for(int i = 2; i <= n; ++i)
    {
        //cout << w[i] << endl;
        if(w[i] % 2 == 1)
        {
            dp[i][0] = dp[i-1][1]+(w[i-1]%2);
            dp[i][1] = dp[i-1][0]+!(w[i-1]%2);
        }
        else
        {
            dp[i][0] = dp[i-1][0]+!(w[i-1]%2);
            dp[i][1] = dp[i-1][1]+(w[i-1]%2);
        }
    }
    ll ans = 0;
    for(int i = 2; i <= n; ++i)
    {
        ll add = 0;
        ll mx = w[i];
        ll sum = w[i];
        for(int j = i-1; j >= 1 && i-j<=70; --j)
        {
            if(mx < w[j]) mx = w[j];
            sum += w[j];
            if(mx > sum - mx && sum % 2 == 0)
                add --;
        }
        //cout << dp[i][0] << endl;
        //cout << add << endl;
        add += dp[i][0];
        ans += add;
    }
    printf("%lld\n",ans);
}


 #include<iostream>
#include<queue>
#include<cstring>
#include<vector>
#include<cstdio>
#include<cmath>
#include<map>
#include<string>
using namespace std;
#define ll long long
#define se second
#define fi first
int n;
const int maxn = 300010;
long long arr[maxn];
int w[maxn];
int sum[maxn];
int dp[maxn][2];
int main()
{
    memset(w,0,sizeof(w));
    scanf("%d",&n);
    for(int i = 1 ; i <= n; ++i)
    {
        scanf("%lld",arr+i);
        long long k = 1;
        for(int j = 0; j < 62; ++j, k <<= 1)
        {
            if( k & arr[i] )
                w[i] ++;
        }
        //cout << w[i] << endl;
    }
    dp[1][0] = dp[1][1] = dp[0][0] = dp[0][1] = 0;
    for(int i = 2; i <= n; ++i)
    {
        //cout << w[i] << endl;
        if(w[i] % 2 == 1)
        {
            dp[i][0] = dp[i-1][1]+(w[i-1]%2);
            dp[i][1] = dp[i-1][0]+!(w[i-1]%2);
        }
        else
        {
            dp[i][0] = dp[i-1][0]+!(w[i-1]%2);
            dp[i][1] = dp[i-1][1]+(w[i-1]%2);
        }
    }
    ll ans = 0;
    for(int i = 2; i <= n; ++i)
    {
        ll add = 0;
        ll mx = w[i];
        ll sum = w[i];
        for(int j = i-1; j >= 1 && i-j<=120; --j)
        {
            if(mx < w[j]) mx = w[j];
            sum += w[j];
            if(mx > sum - mx && sum % 2 == 0)
                add --;
        }
        //cout << dp[i][0] << endl;
        //cout << add << endl;
        add += dp[i][0];
        ans += add;
    }
    printf("%lld\n",ans);
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,cnt1[300001],cnt2[2]={1},s[300001];
ll a,ans;
inline ll lowbit(ll x)
{
	return x&(-x);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a);
		while(a)
		{
			a-=lowbit(a);
			++cnt1[i];
		}
	}
	for(int i=1;i<=n;++i)
	{
		s[i]=s[i-1]+cnt1[i];
		ans+=cnt2[s[i]&1];
		int maxx=0,k=i+1;
		for(int j=i,low=max(i-64,1);j>=low;--j)
		{
            while(k>j)
				maxx=max(maxx,cnt1[--k]);
            if(maxx*2>s[i]-s[j-1]&&((s[i]&1)==(s[j-1]&1)))
				--ans;
        }
        ++cnt2[s[i]&1];
	}
	printf("%lld",ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,f[300001][2];
ll a,ans;
bool w[300001];
inline int lowbit(ll x)
{
	return x&(-x);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a);
		int cnt=0;
		while(a)
		{
			a-=lowbit(a);
			++cnt;
		}
		w[i]=(cnt&1);
		ans-=(!w[i]);
	}
	for(int i=1;i<=n;++i)
	{
		if(w[i]&1)
		{
			f[i][0]=f[i-1][1]+1;
			f[i][1]=f[i-1][0];
		}
		else
		{
			f[i][0]=f[i-1][1];
			f[i][1]=f[i-1][0]+1;
		}
		ans+=f[i][1];
	}
	printf("%lld",ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,f[300001][2];
ll a,ans;
bool w[300001];
inline ll lowbit(ll x)
{
	return x&(-x);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a);
		int cnt=0;
		while(a)
		{
			a-=lowbit(a);
			++cnt;
		}
		w[i]=(cnt&1);
		ans-=(!w[i]);
	}
	for(int i=1;i<=n;++i)
	{
		if(w[i]&1)
		{
			f[i][0]=f[i-1][1]+1;
			f[i][1]=f[i-1][0];
		}
		else
		{
			f[i][0]=f[i-1][1];
			f[i][1]=f[i-1][0]+1;
		}
		ans+=f[i][1];
	}
	printf("%lld",ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define int ll
using namespace std;
int n,f[300001][2];
ll a,ans;
bool w[300001];
inline ll lowbit(ll x)
{
	return x&(-x);
}
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a);
		int cnt=0;
		while(a)
		{
			a-=lowbit(a);
			++cnt;
		}
		w[i]=(cnt&1);
		ans-=(!w[i]);
	}
	for(int i=1;i<=n;++i)
	{
		if(w[i]&1)
		{
			f[i][0]=f[i-1][1]+1;
			f[i][1]=f[i-1][0];
		}
		else
		{
			f[i][0]=f[i-1][1];
			f[i][1]=f[i-1][0]+1;
		}
		ans+=f[i][1];
	}
	printf("%lld",ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define ll long long
using namespace std;
ll n,m,a[400000],sum[400000],ans;

int main(){
	scanf("%lld",&n);

	for(ll i=1;i<=n;i++){
		ll a1,maxx=0;
		scanf("%lld",&a1);
		a[i]=__builtin_popcount(a1),sum[i]=sum[i-1]+a[i];
		//ans+=(sum[i]%2==0);
		maxx=max(maxx,a[i]);

		for(ll j=i-1;j>=max(i-64,(ll)1);j--){
			maxx=max(maxx,a[j]);
			if(sum[i]-sum[j-1]>=2*maxx&&(sum[i]-sum[j-1])%2==0)ans++;
		}

		//cout<<ans<<endl;
	}

	cout<<ans;
}


#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=3e5+10;
int n;
int A[N],sum[N],cnt[N][2],G[N];
int main() {
//	freopen("m.out","w",stdout);
	read(n);
	cnt[0][0]=1;
	for(int i=1;i<=n;++i) {
		LL a; read(a);
		for(int j=0;j<61;++j) if(a>>j&1) ++A[i];
		sum[i]=sum[i-1]+A[i];
		cnt[i][0]=cnt[i-1][0]; cnt[i][1]=cnt[i-1][1];
		++cnt[i][sum[i]&1];
//		printf("#%d %d %d\n",i,cnt[i][0],cnt[i][1]);
	}
	LL res=0;
	for(int i=2;i<=n;++i) {
		int MAXV=A[i];
		for(int j=i-1;j>=max(1,i-64);--j) {
			MAXV=max(MAXV,A[j]);
			if((sum[i]-sum[j-1])%2==0&&MAXV>sum[i]-sum[j-1]-MAXV) --res;
		}
		res+=cnt[i-2][sum[i]&1];
//		printf("%d %d\n",i,cnt[i-2][sum[i]&1]);
	}
	printf("%I64d\n",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define maxn 300000
#define ll long long

ll n;
ll a[maxn+5];
ll b[maxn+5];
ll sum[maxn+5];
ll even[maxn+5],odd[maxn+5];

ll find(ll x) {
	ll y=0;
	while(x) {
		if(x&1) y++;
		x>>=1;
	}
	return y;
}

void readin() {
	scanf("%I64d",&n);
	for(ll i=1;i<=n;i++) {
		scanf("%I64d",&a[i]);
		b[i]=find(a[i]);
	}
}

int main() {
	readin();

	for(ll i=1;i<=n;i++) {
		sum[i]=sum[i-1]+b[i];
	}

	for(ll i=1;i<=n;i++) {
		odd[i]=odd[i-1],even[i]=even[i-1];
		if(sum[i]&1) odd[i]++;
		else even[i]++;
	}

	ll ans=0;
	for(ll i=1;i<=n;i++) {
		if(sum[i-1]&1) ans+=odd[n]-odd[i-1];
		else ans+=even[n]-even[i-1];
	}

	for(ll i=1;i<=n;i++) {
		ll m=min(n,i+64);
		ll maxb=b[i],s=0;
		for(ll j=i;j<=m;j++) {
			maxb=max(maxb,b[j]);
			s+=b[j];
			if(2*maxb>s&&(s&1)==0) ans--;
		}
	}

	printf("%I64d",ans);

	return 0;
}

//---------------------


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll a[300050], cnt[300050], s[300050], d[300050];

void read(ll &rem){
	rem = 0; char c =  getchar();
	while(c<'0'||c>'9') c = getchar();
	while(c>='0'&&c<='9') rem = rem*10+c-48, c = getchar();
}

inline ll push(ll x){
	ll ans = 0;
	for(int i = 0; (1ll<<i) <= x; i++) ans += (x>>i)&1;
	return ans;
}

int main(){
	ll output = 0;
	ll n;
	read(n);
	for(int i = 1; i <= n; i++){
		ll x;
		read(x);
		a[i] = push(x);
		if(a[i]&1) cnt[i] = d[i-1], d[i]=s[i-1]+1, s[i] = d[i-1];
		else cnt[i] += s[i-1], s[i]++;
	}
	for(int i = 2; i <= n; i++){
		output += cnt[i];
		ll k = a[i], ans = a[i];
		for(int j = i; j >= max(1, i-64); j--){
			k = max(k, a[j]);
			ans += a[j];
			if((!(ans & 1)) && k > (ans>>1)) output--;
		}
	}
	printf("%lld", output);
}


//
//  [Title]
//  OI
//
//  Created by ChrAlpha on 2019/11/15.
//  Last updated on 2019/11/15.
//  Copyright @ 2019年 ChrAlpha. All rights reserved.
//

#include <bits/stdc++.h>

#define int long long
#define lli long long
#define FO(i,x,y) for(int i=(x);i<=(y);++i)
#define DF(i,x,y) for(int i=(x);i>=(y);--i)
#define CL(f,x) memset(f,x,sizeof(f))

using namespace std;

const int sz=3e5+5;

void re(int &x) {
    x=0;char ch=getchar();bool nf=0;
    while(ch<'0' || ch>'9') nf|=(ch=='-'),ch=getchar();
    while(ch>='0' && ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    if(nf) x=-x;
}

inline int cn1(int x) {
	int ret=0;
	while(x) {
		ret+=x%2;
		x/=2;
	}
	return ret;
}

int n,sum[sz],ans[2]={1},cnt1[sz];

signed main() {
	re(n);
	int ret=0;
	FO(i,1,n) {
		int a;re(a);
		cnt1[i]=cn1(a);
		sum[i]=sum[i-1]+cnt1[i];
		ret+=ans[sum[i]%2];
		for(int j=i,k=i+1,mx=0;j>=1 && j>=i-64;--j) {
			while(k>j) {
				mx=max(mx,cnt1[--k]);
			}
			if(mx*2>sum[i]-sum[j-1] && !((sum[i]-sum[j-1])%2)) {
				--ret;
			}
		}
		++ans[sum[i]%2];
	}
	printf("%lld\n",ret);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=3e5+10;
ll n,ans,op;
ll a[N],sum[N],cnt[2];

ll work(ll x){
	ll res=0;
	while(x) res+=x&1,x>>=1;
	return res;
}

int main(){
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) scanf("%lld",&op),a[i]=work(op),sum[i]=sum[i-1]+a[i];
	for(ll i=1;i<=n;i++){
		ll tmp=a[i];
		for(ll j=i-1;j>=max(1ll,i-64);j--){
			tmp=max(tmp,a[j]);
			if(2*tmp<=sum[i]-sum[j-1] && (sum[i]-sum[j-1])%2==0) ans++;
		}
		ans+=cnt[sum[i]%2];
		if(i>=65) cnt[sum[i-65]%2]++;
	}
	printf("%lld",ans);
}


#include <bits/stdc++.h>

using namespace std;

const int N = int(3e5) + 9;

int n;
long long a[N];
int b[N];
int cnt[2][N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] = __builtin_popcountll(a[i]);
    }

    long long res = 0;
    int sufSum = 0;
    cnt[0][n] = 1;
    for (int i = n - 1; i >= 0; --i) {
        int sum = 0, mx = 0, add = 0;
        for (int j = i; j < n && j - i < 65; ++j) {
            sum += b[j];
            mx = max(mx, b[j]);
            if (mx > sum - mx && sum % 2 == 0)
                --add;
        }
        sufSum += b[i];
        add += cnt[sufSum & 1][i + 1];
        res += add;
        cnt[0][i] = cnt[0][i + 1];
        cnt[1][i] = cnt[1][i + 1];
        if (sufSum & 1)
            ++cnt[1][i];
        else
            ++cnt[0][i];
    }
    cout << res << endl;
    return 0;
}


#include<bits/stdc++.h>
#define sz 301010
#define mod 2147483648ll
using namespace std;
typedef long long ll;
struct FastIO
{
    inline FastIO& operator>>(int& x)
    {
        x=0;char f=0,ch=getchar();
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
        return x=(f?-x:x),*this;
    }
    inline FastIO& operator>>(ll& x)
    {
        x=0;char f=0,ch=getchar();
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
        return x=(f?-x:x),*this;
    }
    inline FastIO& operator>>(double& x)
    {
        x=0;char f=0,ch=getchar();
        double d=0.1;
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
        if(ch=='.')
        {
            ch=getchar();
            while(ch<='9'&&ch>='0') x+=d*(ch^48),d*=0.1,ch=getchar();
        }
        return x=(f?-x:x),*this;
    }
}read;
void file()
{
    #ifndef ONLINE_JUDGE
    freopen("a.txt","r",stdin);
    #endif
}
unsigned int log2(int x){unsigned int ret;__asm__ __volatile__ ("bsrl %1, %%eax":"=a"(ret):"m"(x));return ret;}
inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
int cnt[sz];
int sum[sz];
int n;
int count(ll x)
{
	int ret=0;
	while (x) ret++,x-=(x&(-x));
	return ret;
}
int main()
{
	file();
	int i,j,k,x,y;
	ll z;
	read>>n;
	for (i=1;i<=n;i++) read>>z,sum[i]=sum[i-1]+(cnt[i]=count(z));
	ll ans=0,odd=0,even=1;
	for (i=1;i<=n;i++)
	{
		(sum[i]&1)?ans+=odd++:ans+=even++;
		if ((sum[i]-sum[i-1])%2==0) ans--;
	}
	for (i=1;i<=n;i++)
	{
		int s=cnt[i],mx=cnt[i];
		for (j=i-1;i-j<=66&&j;j--)
		{
			s+=cnt[i];mx=max(mx,cnt[j]);
			if (mx>s-mx) --ans;
		}
	}
	cout<<ans;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 300010;

int n,cnt[2];
ll a[N],x,ans,len1[N],len[N];
int main(){
//	freopen("1.in","r",stdin);
	scanf("%d",&n);
//	ans=n*(n+1)/2;////
	cnt[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		x=a[i];
		while(x){
			if(x&1) len1[i]++;
			x>>=1;
		}
		len[i]=len[i-1]+len1[i];
		ans+=cnt[len[i]&1];
		int m=max(1,i-64);
		for(int j=i;j>=m;j--){
			ll maxn=0;
			for(int k=i;k>=j;k--)
				maxn=max(maxn,len1[k]);
			if(maxn*2>len[i]-len[j-1]&&!((len[i]-len[j-1])&1)) --ans;
		}
		++cnt[len[i]&1];

	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define rll register long long
#define For(i,l,r) for(rll i=l;i<=r;i++)
using namespace std;
ll n,x,ans,sum;
ll cnt[2],pw[70];
inline void read(ll &x){
	x=0; ll f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); }
	while('0'<=ch && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	x*=f;
}
int main(){
	read(n);
	pw[0]=1; For(i,1,62) pw[i]=pw[i-1]*2;
	cnt[0]++;
	For(i,1,n){
		read(x); ll tot=0;
		For(i,0,62) if(x&pw[i]) tot++;
		ans+=cnt[tot&1];
		sum=sum^(tot&1);
		cnt[sum]++;
	}
	printf("%lld",ans);
}


#include<bits/stdc++.h>

using namespace std;
typedef long long LL;
const int N = 1e5 + 7;

int n;

int b[N];
int sum[N];
int odd[N], even[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) {
		LL x;
		scanf("%lld", &x);
		while (x) {
			if (x % 2LL == 1LL) b[i]++;
			x >>= 1LL;
		}
	}
	for (int i = n; i >= 1; -- i) {
		sum[i] = sum[i + 1] + b[i];
		odd[i] = odd[i + 1], even[i] = even[i + 1];
		if (sum[i] % 2 == 0) even[i]++;
		else odd[i]++;
	}
	LL ans = 0;
	for (int i = 0; i <= n; ++ i) {
		if (sum[i] % 2 == 0) ans += even[i + 1];
		else ans += odd[i + 1];
		int Max = 0;
		if (i == 0) continue;
		for (int j = i; j <= min(n, i + 65); ++ j) {
			Max = max(Max, b[j]);
			int tmp = sum[i] - sum[j + 1];
			if ((tmp % 2 == 0) && (Max + Max) > tmp) ans--;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define ll long long
using namespace std;
ll n,m,a[400000],sum[400000],c[5]={1},ans;

int main(){
	//freopen("C:/t.txt","r",stdin);
	scanf("%lld",&n);

	for(ll i=1;i<=n;i++){
		ll a1,maxx=0;
		scanf("%lld",&a1);
		a[i]=__builtin_popcount(a1),sum[i]=sum[i-1]+a[i];
		maxx=max(maxx,a[i]);
		ans+=c[sum[i]%2];

		for(ll j=i;j>=max(i-64,(ll)1);j--){
			maxx=max(maxx,a[j]);
			if(sum[i]-sum[j-1]<2*maxx&&(sum[i]-sum[j-1])%2==0)ans--;
		}

		++c[sum[i]%2];
	}

	cout<<ans;
}


#include<iostream>
using namespace std;
long long n,m,i,j,ans,ji,ou=1,a[300001],f[300001];
int count(unsigned int x){
    unsigned int c =0 ;
    for (c=0;x;++c){
       x&=(x-1);
    }
    return c;
}
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
		a[i]=count(a[i]);
	}
	for(i=1;i<=n;i++){
		f[i]=f[i-1]+a[i];
		if(f[i]%2){
			ans+=ji;
			ji++;
		}else{
			ans+=ou;
			ou++;
		}
	}
	for(i=1;i<=n;i++){
		m=a[i];
		for(j=i;j<=min(i+64,n);j++){
			m=max(m,a[j]);
			if(2*m>f[j]-f[i-1]&&(f[j]-f[i-1])%2==0){
				ans--;
			}
		}
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll a[300050], cnt[300050];

void read(ll &rem){
	rem = 0; char c =  getchar();
	while(c<'0'||c>'9') c = getchar();
	while(c>='0'&&c<='9') rem = rem*10+c-48, c = getchar();
}

inline ll push(ll x){
	ll ans = 0;
	for(int i = 0; (1ll<<i) <= x; i++) ans += (x>>i)&1;
	return ans;
}

int main(){
	ll output = 0, s = 0, d = 0;
	ll n;
	read(n);
	for(int i = 1; i <= n; i++){
		ll x;
		read(x);
		a[i] = push(x);
		ll ls = s, ld = d;
		if(a[i]&1) cnt[i] = ld, d=ls+1, s = ld;
		else cnt[i] += s, s++;
	}
	for(int i = 2; i <= n; i++){
		output += cnt[i];
		ll k = a[i], ans = a[i];
		for(int j = i; j >= max(1, i-70); j--){
			k = max(k, a[j]);
			ans += a[j];
			if((!(ans & 1)) && k > (ans>>1)) output--;
		}
	}
	printf("%lld", output);
}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 3e5 + 7;

int a[N], b[N], c[N];

int32_t main() {
        int n; cin >> n;
        for(int i = 1; i <= n; i++) {
                cin >> a[i];
                a[i] = __builtin_popcountll(a[i]);
                b[i] = b[i - 1] + a[i];
                c[i] = c[i - 1] + (b[i] & 1LL);
        }

        int ans = 0;
        for(int i = 1; i <= n; i++) {
                int mx = 0;
                for(int j = i; j <= min(i + 64, n); j++) {
                        mx = max(mx, a[j]);
                        if(b[i - 1] % 2 != b[j] % 2) continue;
                        if(b[i - 1] % 2 == b[j] % 2 && mx > (b[j] - b[i - 1]) / 2LL) continue;
                        ++ans;
                }
                int l = i + 64 + 1, r = n;
                if(l <= r) {
                        if(b[i - 1] % 2) ans += c[n] - c[l - 1];
                        else             ans += r - l + 1 - (c[n] - c[l - 1]);
                }
        }

        cout << ans << endl;

}


#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 3e5 + 7;

int a[N], b[N], c[N];

int32_t main() {
        int n; cin >> n;
        for(int i = 1; i <= n; i++) {
                cin >> a[i];
                a[i] = __builtin_popcountll(a[i]);
                b[i] = b[i - 1] + a[i];
                c[i] = c[i - 1] + (b[i] & 1LL);
        }

        int ans = 0;
        for(int i = 1; i <= n; i++) {
                int mx = 0;
                for(int j = i; j <= min(i + 64, n); j++) {
                        mx = max(mx, a[j]);
                        if(b[i - 1] % 2 != b[j] % 2) continue;
                        if(b[i - 1] % 2 == b[j] % 2 && mx > (b[j] - b[i - 1]) / 2) continue;
                        ++ans;
                }
                int l = i + 64 + 1, r = n;
                if(l <= r) {
                        if(a[i - 1] % 2) ans += c[n] - c[l - 1];
                        else             ans += r - l + 1 - (c[n] - c[l - 1]);
                }
        }

        cout << ans << endl;

}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second

using namespace std;

const int N=3e5+10;

int a[N], pref[N], c[N], nc[N], lst[N][61];

int main()
{

    ios_base::sync_with_stdio(0);

    int n;
    cin>>n;

    for (int i=1; i<=n; i++){
        ll c;
        cin>>c;
        a[i]=0; int j=0;
        while ((1LL<<j)<=c){
            if (c&(1LL<<j)){
                a[i]++;
            }
            j++;
        }
    }

    for (int j=1; j<=60; j++){
        lst[0][j]=-1;
    }

    pref[0]=0; nc[0]=0; c[0]=1;
    for (int i=1; i<=n; i++){
        pref[i]=pref[i-1]+a[i];
        c[i]=c[i-1]; nc[i]=nc[i-1];
        if (pref[i]&1){
            nc[i]++;
        }
        else {
            c[i]++;
        }
        for (int j=1; j<=60; j++){
            lst[i][j]=lst[i-1][j];
        }
        lst[i][a[i]]=i;
    }

    ll ans=0;
    for (int i=1; i<=n; i++){

        int maxpref=-1, max2=-1;

        for (int max1=60; max1>0; max1--){

            if (pref[i]<2*max1){
                continue;
            }

            int l=0, r=i-1;
            while (l!=r){

                int mid=(l+r+1)/2;

                if (pref[i]-pref[mid]>=2*max1){
                    l=mid;
                }
                else {
                    r=mid-1;
                }

            }

            int mid=l;
            if (mid>maxpref){

                if (pref[i]&1){

                    if (maxpref==-1){
                        ans+=nc[mid];
                    }
                    else {
                        ans+=nc[mid]-nc[maxpref];
                    }

                }
                else {

                    if (maxpref==-1){
                        ans+=c[mid];
                    }
                    else {
                        ans+=c[mid]-c[maxpref];
                    }

                }

                maxpref=max(maxpref, mid);

            }

            max2=max(max2, lst[i][max1]);
            maxpref=max(maxpref, max2);

        }
        //cout<<ans<<"\n";

    }

    if (!(a[1]&1)){
        ans--;
    }

    cout<<ans<<"\n";

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second

using namespace std;

const int N=3e5+10;

int a[N], pref[N], c[N], nc[N], lst[N][61];

int main()
{

    ios_base::sync_with_stdio(0);

    int n;
    cin>>n;

    for (int i=1; i<=n; i++){
        ll c;
        cin>>c;
        a[i]=0; int j=0;
        while ((1LL<<j)<=c){
            if (c&(1LL<<j)){
                a[i]++;
            }
            j++;
        }
    }

    for (int j=1; j<=60; j++){
        lst[0][j]=-1;
    }

    pref[0]=0; nc[0]=0; c[0]=1;
    for (int i=1; i<=n; i++){
        pref[i]=pref[i-1]+a[i];
        c[i]=c[i-1]; nc[i]=nc[i-1];
        if (pref[i]&1){
            nc[i]++;
        }
        else {
            c[i]++;
        }
        for (int j=1; j<=60; j++){
            lst[i][j]=lst[i-1][j];
        }
        lst[i][a[i]]=i;
    }

    ll ans=0;
    for (int i=2; i<=n; i++){

        int maxpref=-1, max2=-1;

        for (int max1=60; max1>0; max1--){

            if (pref[i]<2*max1){
                continue;
            }

            if (lst[i][max1]==-1){
                continue;
            }

            int l=0, r=i-2;
            while (l!=r){

                int mid=(l+r+1)/2;

                if (pref[i]-pref[mid]>=2*max1){
                    l=mid;
                }
                else {
                    r=mid-1;
                }

            }

            int mid=l;
            if (mid>maxpref){

                if (pref[i]&1){

                    if (maxpref==-1){
                        ans+=nc[mid];
                    }
                    else {
                        ans+=nc[mid]-nc[maxpref];
                    }

                }
                else {

                    if (maxpref==-1){
                        ans+=c[mid];
                    }
                    else {
                        ans+=c[mid]-c[maxpref];
                    }

                }

                maxpref=max(maxpref, mid);

            }

            max2=max(max2, lst[i][max1]);
            maxpref=max(maxpref, max2);

        }
        //cout<<ans<<"\n";

    }

    cout<<ans<<"\n";

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second

using namespace std;

const int N=3e5+10;

int a[N], pref[N], c[N], nc[N], lst[N][61];

int main()
{

    ios_base::sync_with_stdio(0);

    int n;
    cin>>n;

    for (int i=1; i<=n; i++){
        ll c;
        cin>>c;
        a[i]=0; int j=0;
        while ((1LL<<j)<=c){
            if (c&(1LL<<j)){
                a[i]++;
            }
            j++;
        }
    }

    for (int j=1; j<=60; j++){
        lst[0][j]=-1;
    }

    pref[0]=0; nc[0]=0; c[0]=1;
    for (int i=1; i<=n; i++){
        pref[i]=pref[i-1]+a[i];
        c[i]=c[i-1]; nc[i]=nc[i-1];
        if (pref[i]&1){
            nc[i]++;
        }
        else {
            c[i]++;
        }
        for (int j=1; j<=60; j++){
            lst[i][j]=lst[i-1][j];
        }
        lst[i][a[i]]=i;
    }

    ll ans=0;
    for (int i=2; i<=n; i++){

        int maxpref=-1, max2=-1;

        for (int max1=60; max1>0; max1--){

            if (pref[i]<2*max1){
                continue;
            }

            if (lst[i][max1]==-1){
                continue;
            }

            int l=0, r=i-2;
            while (l!=r){

                int mid=(l+r+1)/2;

                if (pref[i]-pref[mid]>=2*max1){
                    l=mid;
                }
                else {
                    r=mid-1;
                }

            }

            int mid=l;
            mid=min(mid, lst[i][max1]-1);
            if (mid>maxpref){

                if (pref[i]&1){

                    if (maxpref==-1){
                        ans+=nc[mid];
                    }
                    else {
                        ans+=nc[mid]-nc[maxpref];
                    }

                }
                else {

                    if (maxpref==-1){
                        ans+=c[mid];
                    }
                    else {
                        ans+=c[mid]-c[maxpref];
                    }

                }

                maxpref=max(maxpref, mid);

            }

            max2=max(max2, lst[i][max1]);
            maxpref=max(maxpref, max2);

        }
        //cout<<ans<<"\n";

    }

    cout<<ans<<"\n";

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second

using namespace std;

const int N=3e5+10;

int a[N], suff[N], c[N], nc[N];

int main()
{

    ios_base::sync_with_stdio(0);

    int n;
    cin>>n;

    for (int i=1; i<=n; i++){
        ll c;
        cin>>c;
        int j=0;
        while ((1LL<<j)<=c){
            if (c&(1LL<<j)){
                a[i]++;
            }
            j++;
        }
    }

    int cur=0;
    c[n+1]=1;
    for (int i=n; i>0; i--){
        c[i]=c[i+1]; nc[i]=nc[i+1];
        cur+=a[i];
        if (cur&1){
            nc[i]++;
        }
        else {
            c[i]++;
        }
        suff[i]=cur;
    }

    ll ans=0;
    for (int l=1; l<n; l++){

        if (suff[l]&1){
            ans+=nc[l+2];
        }
        else {
            ans+=c[l+2];
        }

        cur=a[l]; int max1=a[l];
        for (int r=l+1; r<=min(l+61, n); r++){

            cur+=a[r];
            max1=max(max1, a[r]);

            if (!(cur&1) && max1*2>cur){
                ans--;
            }

        }

        //cout<<ans<<" ";

    }
    //cout<<"\n";

    cout<<ans<<"\n";

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second

using namespace std;

const int N=3e5+10;

int a[N], pref[N], c[N], nc[N], lst[N][61];

int main()
{

    ios_base::sync_with_stdio(0);

    int n;
    cin>>n;

    for (int i=1; i<=n; i++){
        ll c;
        cin>>c;
        a[i]=0; int j=0;
        while ((1LL<<j)<=c){
            if (c&(1LL<<j)){
                a[i]++;
            }
            j++;
        }
    }

    for (int j=1; j<=60; j++){
        lst[0][j]=-1;
    }

    pref[0]=0; nc[0]=0; c[0]=1;
    for (int i=1; i<=n; i++){
        pref[i]=pref[i-1]+a[i];
        c[i]=c[i-1]; nc[i]=nc[i-1];
        if (pref[i]&1){
            nc[i]++;
        }
        else {
            c[i]++;
        }
        for (int j=1; j<=60; j++){
            lst[i][j]=lst[i-1][j];
        }
        lst[i][a[i]]=i;
    }

    ll ans=0;
    for (int i=2; i<=n; i++){

        int maxpref=-1, max2=-1;

        for (int max1=60; max1>0; max1--){

            if (pref[i]<2*max1){
                continue;
            }

            if (lst[i][max1]==-1){
                continue;
            }

            int l=0, r=i-2;
            while (l!=r){

                int mid=(l+r+1)/2;

                if (pref[i]-pref[mid]>=2*max1){
                    l=mid;
                }
                else {
                    r=mid-1;
                }

            }

            int mid=l;
            mid=min(mid, lst[i][max1]);
            if (mid>maxpref){

                if (pref[i]&1){

                    if (maxpref==-1){
                        ans+=nc[mid];
                    }
                    else {
                        ans+=nc[mid]-nc[maxpref];
                    }

                }
                else {

                    if (maxpref==-1){
                        ans+=c[mid];
                    }
                    else {
                        ans+=c[mid]-c[maxpref];
                    }

                }

                maxpref=max(maxpref, mid);

            }

            max2=max(max2, lst[i][max1]);
            maxpref=max(maxpref, max2);

        }
        //cout<<ans<<"\n";

    }

    cout<<ans<<"\n";

    return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ(a) (a)*(a)
#define all(v) v.begin(), v.end()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int MAX_N = 300000;
int n;
ll arr[MAX_N];
ll pref[MAX_N];
ll prefEven[MAX_N];

ll countEven(int k) { // count number of evens in pref <= k
    if(k < 0) return 1;
    return prefEven[k]+1;
}

ll countOdd(int k) {
    if(k < 0) return 0;
    return k+1 - prefEven[k];
}

int main() { FAST
    cin >> n;
    M00(i, n) {
        ll k; cin >> k;
        arr[i] = __builtin_popcountll(k);
    }
    pref[0] = arr[0];
    MOO(i, 1, n) pref[i] = pref[i-1] + arr[i];
    prefEven[0] = (pref[0]%2 == 0);
    MOO(i, 1, n) prefEven[i] = prefEven[i-1] + (pref[i]%2 == 0);

    ll res = 0;
    MOO(r, 119, n) {
        if(pref[r]%2 == 0) {
            res += countEven(r-120);
        } else {
            res += countOdd(r-120);
        }
    }

    M00(l, n) {
        ll s = arr[l];
        ll mx = arr[l];
        MOO(r, l+1, min(n, l+119)) {
            mx = max(mx, arr[r]);
            s += arr[r];
            if(s%2 == 0 && s >= 2*mx) res++;
        }
    }
    finish(res);
}


#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ(a) (a)*(a)
#define all(v) v.begin(), v.end()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int MAX_N = 300000;
int n;
ll arr[MAX_N];
ll pref[MAX_N];
ll prefEven[MAX_N];

ll countEven(int k) { // count number of evens in pref <= k
    if(k < 0) return 0;
    return prefEven[k];
}

ll countOdd(int k) {
    if(k < 0) return 0;
    return k+1 - prefEven[k];
}

int main() { FAST
    cin >> n;
    M00(i, n) {
        ll k; cin >> k;
        arr[i] = __builtin_popcountll(k);
    }
    pref[0] = arr[0];
    MOO(i, 1, n) pref[i] = pref[i-1] + arr[i];
    prefEven[0] = (pref[0]%2 == 0);
    MOO(i, 1, n) prefEven[i] = prefEven[i-1] + (pref[i]%2 == 0);

    ll res = 0;
    MOO(r, 119, n) {
        if(pref[r]%2 == 0) {
            res += countEven(r-120);
        } else {
            res += countOdd(r-120);
        }
    }

    M00(l, n) {
        ll s = arr[l];
        ll mx = arr[l];
        MOO(r, l+1, min(n, l+119)) {
            mx = max(mx, arr[r]);
            s += arr[r];
            if(s%2 == 0 && s >= 2*mx) res++;
        }
    }
    finish(res);
}


#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ(a) (a)*(a)
#define all(v) v.begin(), v.end()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int MAX_N = 300000;
int n;
ll arr[MAX_N];
ll pref[MAX_N];
ll prefEven[MAX_N];

ll countEven(int k) { // count number of evens in pref <= k
    if(k < 0) return 0;
    return prefEven[k];
}

ll countOdd(int k) {
    if(k < 0) return 0;
    return k+1 - prefEven[k];
}

int main() { FAST
    cin >> n;
    M00(i, n) {
        ll k; cin >> k;
        arr[i] = __builtin_popcountll(k);
    }
    pref[0] = arr[0];
    MOO(i, 1, n) pref[i] = pref[i-1] + arr[i];
    prefEven[0] = (pref[0]%2 == 0);
    MOO(i, 1, n) prefEven[i] = prefEven[i-1] + (pref[i]%2 == 0);

    ll res = 0;
    MOO(r, 120, n) {
        if(pref[r]%2 == 0) {
            res += countEven(r-120);
        } else {
            res += countOdd(r-120);
        }
    }

    M00(l, n) {
        ll s = arr[l];
        ll mx = arr[l];
        MOO(r, l+1, min(n, l+120)) {
            mx = max(mx, arr[r]);
            s += arr[r];
            if(s%2 == 0 && s >= 2*mx) res++;
        }
    }
    finish(res);
}


#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int M = 300010;
int n;
ll ans = 0;
int cnt[M], sum[M], buc[2];

template <typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(n); buc[0]++;
    for(int i = 1;i <= n; i++){
        ll x; read(x);
        for(;x; x -= x & -x) cnt[i]++;
        sum[i] = sum[i - 1] + cnt[i];
        ans += buc[sum[i] & 1];
        for(int j = i,k = i + 1,mx = 0;j >= 1 && j >= i - 64; j--){
            while(k > j) mx = max(mx,cnt[--k]);
            if(mx * 2 > sum[i] - sum[j - 1] && ((sum[i] & 1) == (sum[j - 1] & 1))) ans--;
        }
        buc[sum[i] & 1]++;
    }
    printf("%lld\n",ans);
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int M = 310;
int n;
ll ans = 0;
int cnt[M], sum[M], buc[2];

template <typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(n); buc[0]++;
    for(int i = 1;i <= n; i++){
        ll x; read(x);
        for(;x; x -= x & -x) cnt[i]++;
        sum[i] = sum[i - 1] + cnt[i];
        ans += buc[sum[i] & 1];
        for(int j = i,k = i + 1,mx = 0;j >= 1 && j >= i - 64; j--){
            while(k > j) mx = max(mx,cnt[--k]);
            if(mx * 2 > sum[i] - sum[j - 1] && ((sum[i] & 1) == (sum[j - 1] & 1))) ans--;
        }
        buc[sum[i] & 1]++;
    }
    printf("%lld\n",ans);
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int M = 310;
int n, ans = 0;
int cnt[M], sum[M], buc[2];

template <typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(n);
    for(int i = 1;i <= n; i++){
        ll x; read(x);
        for(;x; x >>= 1) cnt[i] += (x & 1);
    }
    for(int i = 1;i <= n; i++) sum[i] = (sum[i - 1] + cnt[i]) % 2;
    for(int i = 1;i <= n; i++){
        ans += buc[sum[i]]; buc[sum[i]]++;
        if(i != 1 && sum[i] == 0) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=3e5+10;
int a[MAXN];
int odd[MAXN];
int even[MAXN];
int tp[MAXN];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        ll x;
        cin>>x;
        while(x){
            x-=x&-x;
            a[i]++;
        }
        if(i==1){
            if(a[i]&1){
                odd[i]++;
            }else{
                even[i]++;
            }
        }else{
            if(a[i]&1){
                if(odd[i-1]-odd[i-2]==1){
                    even[i]++;
                }else{
                    odd[i]++;
                }
            }else{
                if(even[i-1]-even[i-2]==1){
                    odd[i]++;
                }else{
                    even[i]++;
                }
            }
        }
        odd[i]+=odd[i-1];
        even[i]+=even[i-1];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        if(i!=1&&odd[i-1]-odd[i-2]==1){
            ans+=odd[n]-odd[i];
            int mx=a[i];
            ll sum=a[i];
            for(int j=i+1;j<=n&&j-i<=62;j++){
                mx=max(mx,a[j]);
                sum+=a[j];
                if(odd[j]-odd[j-1]==1&&mx>sum-mx){
                    ans--;
                }
            }
        }else{
            ans+=even[n]-even[i];
            int mx=a[i];
            ll sum=a[i];
            for(int j=i+1;j<=n&&j-i<=62;j++){
                mx=max(mx,a[j]);
                sum+=a[j];
                if(even[j]-even[j-1]==1&&mx>sum-mx){
                    ans--;
                }
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=3e5+10;
int a[MAXN];
int odd[MAXN];
int even[MAXN];
int tp[MAXN];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        ll x;
        cin>>x;
        while(x){
            x-=x&-x;
            a[i]++;
        }
        if(i==1){
            if(a[i]&1){
                odd[i]++;
            }else{
                even[i]++;
            }
        }else{
            if(a[i]&1){
                if(odd[i-1]-odd[i-2]==1){
                    even[i]++;
                }else{
                    odd[i]++;
                }
            }else{
                if(even[i-1]-even[i-2]==1){
                    odd[i]++;
                }else{
                    even[i]++;
                }
            }
        }
        odd[i]+=odd[i-1];
        even[i]+=even[i-1];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        if(i!=1&&odd[i-1]-odd[i-2]==1){
            ans+=odd[n]-odd[i];
            int mx=a[i];
            ll sum=a[i];
            for(int j=i+1;j<=n&&j-i<=61;j++){
                mx=max(mx,a[j]);
                sum+=a[j];
                if(odd[j]-odd[j-1]==1&&mx>sum-mx){
                    ans--;
                }
            }
        }else{
            ans+=even[n]-even[i];
            int mx=a[i];
            ll sum=a[i];
            for(int j=i+1;j<=n&&j-i<=61;j++){
                mx=max(mx,a[j]);
                sum+=a[j];
                if(even[j]-even[j-1]==1&&mx>sum-mx){
                    ans--;
                }
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=3e5+10;
int a[MAXN];
int odd[MAXN];
int even[MAXN];
int tp[MAXN];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        ll x;
        cin>>x;
        while(x){
            x-=x&-x;
            a[i]++;
        }
        if(i==1){
            if(a[i]&1){
                odd[i]++;
                tp[i]=1;
            }else{
                even[i]++;
                tp[i]=0;
            }
        }else{
            if(a[i]&1){
                if(tp[i-1]==1){
                    even[i]++;
                    tp[i]=0;
                }else{
                    odd[i]++;
                    tp[i]=1;
                }
            }else{
                if(tp[i-1]==1){
                    odd[i]++;
                    tp[i]=1;
                }else{
                    even[i]++;
                    tp[i]=0;
                }
            }
        }
        odd[i]+=odd[i-1];
        even[i]+=even[i-1];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        if(i!=1&&tp[i-1]==1){
            ans+=odd[n]-odd[i];
            int mx=a[i];
            ll sum=a[i];
            for(int j=i+1;j<=n&&j-i<=62;j++){
                mx=max(mx,a[j]);
                sum+=a[j];
                if(tp[j]==1&&mx>sum-mx){
                    ans--;
                }
            }
        }else{
            ans+=even[n]-even[i];
            int mx=a[i];
            ll sum=a[i];
            for(int j=i+1;j<=n&&j-i<=62;j++){
                mx=max(mx,a[j]);
                sum+=a[j];
                if(tp[j]==0&&mx>sum-mx){
                    ans--;
                }
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

const long long INF = 1e9 + 1, MOD = 998244353;

typedef long long ll;

ll n, a[300000], even, odd, ans;

int main ()
{
	cin >> n;

	for (ll i = 0LL; i < n; i++)
	{
		scanf ("%I64d", &a[i]);

		ll b = 0LL;

		while (a[i])
		{
			b += a[i] % 2LL;

			a[i] /= 2LL;
		}

		a[i] = b;

		if (b % 2LL)
		{
			swap (even, odd);
			odd++;
		}
		else even++;

		ans += even;

		if (b % 2LL == 0LL) ans--;

		ll mx = a[i], sum = a[i];

		for (ll j = i - 1; j >= max (0LL, i - 100); j--)
		{
			sum += a[j];
			mx = max (a[j], mx);

			if (sum - mx < mx && sum % 2LL == 0LL) ans--;
		}
	}

	cout << ans;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

const long long INF = 1e9 + 1, MOD = 998244353;

typedef long long ll;

ll n, a[300000], even, odd, ans;

int main ()
{
	cin >> n;

	for (ll i = 0LL; i < n; i++)
	{
		scanf ("%I64d", &a[i]);

		ll b = 0LL;

		while (a[i])
		{
			b += a[i] % 2LL;

			a[i] /= 2LL;
		}

		a[i] = b;

		if (b % 2LL)
		{
			swap (even, odd);
			odd++;
		}
		else if (odd) odd++;

		ans += even;

		if (b % 2LL == 0LL) even++;

		ll mx = a[i], sum = a[i];

		for (ll j = i - 1; j >= max (0LL, i - a[i]); j--)
		{
			sum += a[j];
			mx = max (a[j], mx);

			if (sum < mx && sum % 2LL == 0LL) ans--;
		}
	}

	cout << ans;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

const long long INF = 1e9 + 1, MOD = 9982LL44353;

typedef long long ll;

ll n, a[300000], even, odd, ans;

int main ()
{
	cin >> n;

	for (ll i = 0LL; i < n; i++)
	{
		scanf ("%I64d", &a[i]);

		ll b = 0LL;

		while (a[i])
		{
			b += a[i] % 2LL;

			a[i] /= 2LL;
		}

		a[i] = b;

		if (b % 2LL)
		{
			swap (even, odd);
			odd++;
		}
		else if (odd) odd++;

		ans += even;

		if (b % 2LL == 0LL) even++;

		ll mx = a[i], sum = a[i];

		for (ll j = i - 1; j >= max (0LL, i - a[i]); j--)
		{
			sum += a[j];
			mx = max (a[j], mx);

			if (sum < mx && sum % 2LL == 0LL) ans--;
		}
	}

	cout << ans;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

const long long INF = 1e9 + 1, MOD = 998244353;

typedef long long ll;

ll n, a[300000], even, odd, ans;

int main ()
{
	cin >> n;

	for (ll i = 0LL; i < n; i++)
	{
		scanf ("%I64d", &a[i]);

		ll b = 0LL;

		while (a[i])
		{
			b += a[i] % 2LL;

			a[i] /= 2LL;
		}

		a[i] = b;

		if (b % 2LL)
		{
			swap (even, odd);
			odd++;
		}
		else even++;

		ans += even;

		if (b % 2LL == 0LL) ans--;

		ll mx = a[i], sum = a[i];

		for (ll j = i - 1; j >= max (0LL, i - a[i]); j--)
		{
			sum += a[j];
			mx = max (a[j], mx);

			if (sum - mx < mx && sum % 2LL == 0LL) ans--;
		}
	}

	cout << ans;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

const long long INF = 1e9 + 1, MOD = 9982LL44353;

typedef long long ll;

ll n, a[30LL0LL0LL0LL0LL], even, odd, ans;

int main ()
{
	cin >> n;

	for (int i = 0LL; i < n; i++)
	{
		scanf ("%I64d", &a[i]);

		int b = 0LL;

		while (a[i])
		{
			b += a[i] % 2LL;

			a[i] /= 2LL;
		}

		a[i] = b;

		if (b % 2LL)
		{
			swap (even, odd);
			odd++;
		}
		else if (odd) odd++;

		ans += even;

		if (b % 2LL == 0LL) even++;

		int mx = a[i], sum = a[i];

		for (int j = i - 1; j >= max (0LL, i - a[i]); j--)
		{
			sum += a[j];
			mx = max (a[j], mx);

			if (sum < mx && sum % 2LL == 0LL) ans--;
		}
	}

	cout << ans;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

const long long INF = 1e9 + 1, MOD = 998244353;

typedef long long ll;

ll n, a[300000], even, odd, ans;

int main ()
{
	cin >> n;

	for (ll i = 0LL; i < n; i++)
	{
		scanf ("%I64d", &a[i]);

		ll b = 0LL;

		while (a[i])
		{
			b += a[i] % 2LL;

			a[i] /= 2LL;
		}

		a[i] = b;

		if (b % 2LL)
		{
			swap (even, odd);
			odd++;
		}

		ans += even;

		if (b % 2LL == 0LL) even++;

		ll mx = a[i], sum = a[i];

		for (ll j = i - 1; j >= max (0LL, i - a[i]); j--)
		{
			sum += a[j];
			mx = max (a[j], mx);

			if (sum - mx < mx && sum % 2LL == 0LL) ans--;
		}
	}

	cout << ans;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

const long long INF = 1e9 + 1, MOD = 998244353;

typedef long long ll;

int n, a[300000], even, odd, ans;

int main ()
{
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		scanf ("%d", &a[i]);

		int b = 0;

		while (a[i])
		{
			b += a[i] % 2;

			a[i] /= 2;
		}

		a[i] = b;

		if (b % 2)
		{
			swap (even, odd);
			odd++;
		}
		else if (odd) odd++;

		ans += even;

		if (b % 2 == 0) even++;

		int mx = a[i], sum = a[i];

		for (int j = i - 1; j >= max (0, i - a[i]); j--)
		{
			sum += a[j];
			mx = max (a[j], mx);

			if (sum < mx && sum % 2 == 0) ans--;
		}
	}

	cout << ans;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

const long long INF = 1e9 + 1, MOD = 9982LL44353;

typedef long long ll;

ll n, a[30LL0LL0LL0LL0LL], even, odd, ans;

int main ()
{
	cin >> n;

	for (ll i = 0LL; i < n; i++)
	{
		scanf ("%I64d", &a[i]);

		ll b = 0LL;

		while (a[i])
		{
			b += a[i] % 2LL;

			a[i] /= 2LL;
		}

		a[i] = b;

		if (b % 2LL)
		{
			swap (even, odd);
			odd++;
		}
		else if (odd) odd++;

		ans += even;

		if (b % 2LL == 0LL) even++;

		ll mx = a[i], sum = a[i];

		for (ll j = i - 1; j >= max (0LL, i - a[i]); j--)
		{
			sum += a[j];
			mx = max (a[j], mx);

			if (sum < mx && sum % 2LL == 0LL) ans--;
		}
	}

	cout << ans;
}


#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <set>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

const long long INF = 1e9 + 1, MOD = 998244353;

typedef long long ll;

ll n, a[300000], even, odd, ans;

int main ()
{
	cin >> n;

	for (ll i = 0LL; i < n; i++)
	{
		scanf ("%I64d", &a[i]);

		ll b = 0LL;

		while (a[i])
		{
			b += a[i] % 2LL;

			a[i] /= 2LL;
		}

		a[i] = b;

		if (b % 2LL)
		{
			swap (even, odd);
			odd++;
		}
		else even++;

		ans += even;

		if (b % 2LL == 0LL) ans--;

		ll mx = a[i], sum = a[i];

		for (ll j = i - 1; j >= max (0LL, i - a[i] - 10); j--)
		{
			sum += a[j];
			mx = max (a[j], mx);

			if (sum - mx < mx && sum % 2LL == 0LL) ans--;
		}
	}

	cout << ans;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N (300010)
#define M (70)
int a[N], f[M], g[M], low[N], high[N];
int n;
int n1(LL x) {
	int res = 0;
	while (x) {
		res++;
		x -= x&-x;
	}
	return res;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		LL tmp;
		scanf("%I64d", &tmp);
		a[i] = n1(tmp);
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x = a[i];
		for (int l = max(1, i-64); l < i; ++l) {
			if (x <= low[l] || x >= high[l]) {
				low[l] = abs(x - low[l]);
			}
			else {
				low[l] = (x ^ low[l]) & 1;
			}
			high[l] = x+high[l];
		}
		low[i] = high[i] = x;
		if (i-64 > 0) {
			for (int j = 0; j <= 64; ++j) {
				g[j] = 0;
			}
			for (int j = 0; j <= x; ++j) {
				g[(j^x)&1] += f[j];
			}
			for (int j = x+1; j <= 64; ++j) {
				g[j-x] += f[j];
			}
			g[low[i-64]]++;
			for (int j = 0; j <= 64; ++j) {
				f[i] = g[i];
			}
		}

		if (i-64 > 0) {
			ans += f[0];
		}
		for (int j = max(1, i-63); j <= i; ++j) {
			ans += low[j] == 0;
		}
		// for (int j = 1; j <= i; ++j) {
			// printf("%d %d\n", low[j], high[j]);
		// }
		// printf("\n");
	}
	printf("%I64d\n", ans);
}


#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N (300010)
#define M (70)
int a[N], f[M], g[M], low[N], high[N];
int n;
int n1(LL x) {
	int res = 0;
	while (x) {
		res++;
		x -= x&-x;
	}
	return res;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		LL tmp;
		scanf("%I64d", &tmp);
		a[i] = n1(tmp);
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x = a[i];
		for (int l = max(1, i-64); l < i; ++l) {
			if (x <= low[l] || x >= high[l]) {
				low[l] = abs(x - low[l]);
			}
			else {
				low[l] = (x ^ low[l]) & 1;
			}
			high[l] = x+high[l];
		}
		low[i] = high[i] = x;
		if (i-64 > 0) {
			for (int j = 0; j <= 64; ++j) {
				g[j] = 0;
			}
			for (int j = 0; j <= x; ++j) {
				g[(j^x)&1] += f[j];
			}
			for (int j = x+1; j <= 64; ++j) {
				g[j-x] += f[j];
			}
			g[low[i-64]]++;
			// printf("low i-64 %d\n", low[i-64]);
			for (int j = 0; j <= 64; ++j) {
				f[j] = g[j];
			}
		}

		if (i-64 > 0) {
			ans += f[0];
			// printf("%d %d\n", f[0], f[1]);
		}
		for (int j = max(1, i-63); j <= i; ++j) {
			ans += low[j] == 0;
		}
		// for (int j = 1; j <= i; ++j) {
			// printf("%d %d\n", low[j], high[j]);
		// }
		// printf("\n");
	}
	printf("%I64d\n", ans);
}


#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N (300010)
#define M (800)
#define P (700)
int a[N], f[M], g[M], low[N], high[N];
int n;
int n1(LL x) {
	int res = 0;
	while (x) {
		res++;
		x -= x&-x;
	}
	return res;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		LL tmp;
		scanf("%I64d", &tmp);
		a[i] = n1(tmp);
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x = a[i];
		for (int l = max(1, i-P); l < i; ++l) {
			if (x < low[l] || x > high[l]) {
				low[l] = abs(x - low[l]);
			}
			else {
				low[l] = (x ^ low[l]) & 1;
			}
			high[l] = x+high[l];
		}
		low[i] = high[i] = x;
		if (i-P > 0) {
			for (int j = 0; j <= P; ++j) {
				g[j] = 0;
			}
			for (int j = 0; j <= x; ++j) {
				g[(j^x)&1] += f[j];
			}
			for (int j = x+1; j <= P; ++j) {
				g[j-x] += f[j];
			}
			g[low[i-P]]++;
			// printf("low i-64 %d\n", low[i-64]);
			for (int j = 0; j <= P; ++j) {
				f[j] = g[j];
			}
		}

		if (i-P > 0) {
			ans += f[0];
			// printf("%d %d\n", f[0], f[1]);
		}
		for (int j = max(1, i-P+1); j <= i; ++j) {
			ans += low[j] == 0;
		}
		// for (int j = 1; j <= i; ++j) {
			// printf("%d %d\n", low[j], high[j]);
		// }
		// printf("\n");
	}
	printf("%I64d\n", ans);
}


#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N (300010)
#define M (80)
#define P (70)
int a[N], f[M], g[M], low[N], high[N];
int n;
int n1(LL x) {
	int res = 0;
	while (x) {
		res++;
		x -= x&-x;
	}
	return res;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		LL tmp;
		scanf("%I64d", &tmp);
		a[i] = n1(tmp);
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x = a[i];
		for (int l = max(1, i-P); l < i; ++l) {
			if (x <= low[l] || x >= high[l]) {
				low[l] = abs(x - low[l]);
			}
			else {
				low[l] = (x ^ low[l]) & 1;
			}
			high[l] = x+high[l];
		}
		low[i] = high[i] = x;
		if (i-P > 0) {
			for (int j = 0; j <= P; ++j) {
				g[j] = 0;
			}
			for (int j = 0; j <= x; ++j) {
				g[(j^x)&1] += f[j];
			}
			for (int j = x+1; j <= P; ++j) {
				g[j-x] += f[j];
			}
			g[low[i-P]]++;
			// printf("low i-64 %d\n", low[i-64]);
			for (int j = 0; j <= P; ++j) {
				f[j] = g[j];
			}
		}

		if (i-P > 0) {
			ans += f[0];
			// printf("%d %d\n", f[0], f[1]);
		}
		for (int j = max(1, i-P+1); j <= i; ++j) {
			ans += low[j] == 0;
		}
		// for (int j = 1; j <= i; ++j) {
			// printf("%d %d\n", low[j], high[j]);
		// }
		// printf("\n");
	}
	printf("%I64d\n", ans);
}


#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N (300010)
#define M (70)
int a[N], f[M], g[M], low[N], high[N];
int n;
int n1(LL x) {
	int res = 0;
	while (x) {
		res++;
		x -= x&-x;
	}
	return res;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		LL tmp;
		scanf("%I64d", &tmp);
		a[i] = n1(tmp);
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x = a[i];
		for (int l = max(1, i-64); l < i; ++l) {
			if (x <= low[l] || x >= high[l]) {
				low[l] = abs(x - low[l]);
			}
			else {
				low[l] = (x ^ low[l]) & 1;
			}
			high[l] = x+high[l];
		}
		low[i] = high[i] = x;
		if (i-64 > 0) {
			for (int j = 0; j <= x; ++j) {
				g[(j^x)&1] += f[j];
			}
			for (int j = x+1; j <= 64; ++j) {
				g[j-x] += f[j];
			}
			g[low[i-64]]++;
			for (int j = 0; j <= 64; ++j) {
				f[i] = g[i];
			}
		}

		if (i-64 > 0) {
			ans += f[0];
		}
		for (int j = max(1, i-63); j <= i; ++j) {
			ans += low[j] == 0;
		}
		// for (int j = 1; j <= i; ++j) {
			// printf("%d %d\n", low[j], high[j]);
		// }
		// printf("\n");
	}
	printf("%I64d\n", ans);
}


#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N (300010)
#define M (800)
#define P (700)
int a[N], f[M], g[M], low[N], high[N];
int n;
int n1(LL x) {
	int res = 0;
	while (x) {
		res++;
		x -= x&-x;
	}
	return res;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		LL tmp;
		scanf("%I64d", &tmp);
		a[i] = n1(tmp);
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x = a[i];
		for (int l = max(1, i-P); l < i; ++l) {
			if (x < low[l]) {
				low[l] = abs(x - low[l]);
			}
			else if (x < high[l]){
				low[l] = (x ^ low[l]) & 1;
			}
			else {
				low[l] = x - high[l];
			}
			high[l] = x+high[l];
		}
		low[i] = high[i] = x;
		if (i-P > 0) {
			for (int j = 0; j <= P; ++j) {
				g[j] = 0;
			}
			for (int j = 0; j <= x; ++j) {
				g[(j^x)&1] += f[j];
			}
			for (int j = x+1; j <= P; ++j) {
				g[j-x] += f[j];
			}
			g[low[i-P]]++;
			// printf("low i-64 %d\n", low[i-64]);
			for (int j = 0; j <= P; ++j) {
				f[j] = g[j];
			}
		}

		if (i-P > 0) {
			ans += f[0];
			// printf("%d %d\n", f[0], f[1]);
		}
		for (int j = max(1, i-P+1); j <= i; ++j) {
			ans += low[j] == 0;
		}
		// for (int j = 1; j <= i; ++j) {
			// printf("%d %d\n", low[j], high[j]);
		// }
		// printf("\n");
	}
	printf("%I64d\n", ans);
}


#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N (300010)
#define M (70)
#define P (64)
int a[N], f[M], g[M], low[N], high[N];
int n;
int n1(LL x) {
	int res = 0;
	while (x) {
		res++;
		x -= x&-x;
	}
	return res;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		LL tmp;
		scanf("%I64d", &tmp);
		a[i] = n1(tmp);
	}
	LL ans = 0;
	for (int i = 1; i <= n; ++i) {
		int x = a[i];
		for (int l = max(1, i-P); l < i; ++l) {
			if (x < low[l]) {
				low[l] = abs(x - low[l]);
			}
			else if (x < high[l]){
				low[l] = (x ^ low[l]) & 1;
			}
			else {
				low[l] = x - high[l];
			}
			high[l] = x+high[l];
		}
		low[i] = high[i] = x;
		if (i-P > 0) {
			for (int j = 0; j <= P; ++j) {
				g[j] = 0;
			}
			for (int j = 0; j <= x; ++j) {
				g[(j^x)&1] += f[j];
			}
			for (int j = x+1; j <= P; ++j) {
				g[j-x] += f[j];
			}
			g[low[i-P]]++;
			// printf("low i-64 %d\n", low[i-64]);
			for (int j = 0; j <= P; ++j) {
				f[j] = g[j];
			}
		}

		if (i-P > 0) {
			ans += f[0];
			// printf("%d %d\n", f[0], f[1]);
		}
		for (int j = max(1, i-P+1); j <= i; ++j) {
			ans += low[j] == 0;
		}
		// for (int j = 1; j <= i; ++j) {
			// printf("%d %d\n", low[j], high[j]);
		// }
		// printf("\n");
	}
	printf("%I64d\n", ans);
}


#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;

inline ull read(){
    ull a = 0;
    char c = getchar();
    while(!isdigit(c))
        c = getchar();
    while(isdigit(c)){
        a = (a << 3) + (a << 1) + (c ^ '0');
        c = getchar();
    }
    return a;
}

const int MAXN = 3e5 + 10;
int num[MAXN] , rig[MAXN][65] , lef[MAXN][65] , cnt[MAXN][2] , sum[MAXN] , ST[21][MAXN] , logg2[MAXN] , N;
long long ans;

inline int cmp(int a , int b){
    return num[a] > num[b] ? a : b;
}

void init_st(){
    for(int i = 2 ; i <= N ; ++i)
        logg2[i] = logg2[i >> 1] + 1;
    for(int i = 1 ; 1 << i <= N ; ++i)
        for(int j = 1 ; j + (1 << i) - 1 <= N ; ++j)
            ST[i][j] = cmp(ST[i - 1][j] , ST[i - 1][j + (1 << (i - 1))]);
}

inline int query(int x , int y){
    int t = logg2[y - x + 1];
    return cmp(ST[t][x] , ST[t][y - (1 << t) + 1]);
}

void solve(int l , int r){
    if(l > r)
        return;
    if(l == r){
        ans += num[l] == 0;
        return;
    }
    int k = query(l , r);
    solve(l , k - 1);
    solve(k + 1 , r);
    if(k - l < r - k)
        for(int i = k ; i >= l ; --i)
            ans += cnt[r][sum[i] & 1] - cnt[min(max(k - 1 , rig[i][num[k]]) , r)][sum[i] & 1];
    else
        for(int i = k ; i <= r ; ++i)
            ans += cnt[max(min(k - 1 , lef[i][num[k]]) , l - 1)][sum[i] & 1] - (l == 1 ? 0 : cnt[l - 2][sum[i] & 1]);
}

int main(){
    N = read();
    cnt[0][0] = 1;
    for(int i = 1 ; i <= N ; ++i){
        ull a = read();
        while(a){
            if(a & 1)
                ++num[i];
            a >>= 1;
        }
        sum[i] = sum[i - 1] + num[i];
        cnt[i][0] = cnt[i - 1][0] + !(sum[i] & 1);
        cnt[i][1] = cnt[i - 1][1] + (sum[i] & 1);
        ST[0][i] = i;
    }
    for(int i = 0 ; i <= 64 ; ++i){
        int p = 0;
        for(int j = 1 ; j <= N ; ++j)
            while(p < j && sum[j] - sum[p] >= i << 1)
                rig[++p][i] = j;
        while(p < N)
            rig[++p][i] = N + 1;
        for(int j = N ; j ; --j)
            while(p >= j && sum[p] - sum[j - 1] >= i << 1)
                lef[p--][i] = j;
    }
    init_st();
    solve(1 , N);
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;

inline ull read(){
    ull a = 0;
    char c = getchar();
    while(!isdigit(c))
        c = getchar();
    while(isdigit(c)){
        a = (a << 3) + (a << 1) + (c ^ '0');
        c = getchar();
    }
    return a;
}

const int MAXN = 3e5 + 10;
int num[MAXN] , rig[MAXN][65] , lef[MAXN][65] , cnt[MAXN][2] , sum[MAXN] , ST[21][MAXN] , logg2[MAXN] , N;
long long ans;

inline int cmp(int a , int b){
    return num[a] > num[b] ? a : b;
}

void init_st(){
    for(int i = 2 ; i <= N ; ++i)
        logg2[i] = logg2[i >> 1] + 1;
    for(int i = 1 ; 1 << i <= N ; ++i)
        for(int j = 1 ; j + (1 << i) - 1 <= N ; ++j)
            ST[i][j] = cmp(ST[i - 1][j] , ST[i - 1][j + (1 << (i - 1))]);
}

inline int query(int x , int y){
    int t = logg2[y - x + 1];
    return cmp(ST[t][x] , ST[t][y - (1 << t) + 1]);
}

void solve(int l , int r){
    if(l > r)
        return;
    if(l == r){
        ans += num[l] == 0;
        return;
    }
    int k = query(l , r);
    //cout << l << ' ' << r << ' ' << k << endl;
    solve(l , k - 1);
    solve(k + 1 , r);
    if(k - l < r - k)
        for(int i = k ; i >= l ; --i)
            ans += cnt[r][sum[i - 1] & 1] - cnt[min(max(k - 1 , rig[i][num[k]] - 1) , r)][sum[i - 1] & 1];
    else
        for(int i = k ; i <= r ; ++i)
            if(lef[i][num[k]] >= l)
                ans += cnt[min(k - 1 , lef[i][num[k]] - 1)][sum[i] & 1] - (l == 1 ? 0 : cnt[l - 2][sum[i] & 1]);
    //cout << l << ' ' << r << ' ' << ans << endl;
}

int main(){
    N = read();
    cnt[0][0] = 1;
    for(int i = 1 ; i <= N ; ++i){
        ull a = read();
        while(a){
            if(a & 1)
                ++num[i];
            a >>= 1;
        }
        sum[i] = sum[i - 1] + num[i];
        cnt[i][0] = cnt[i - 1][0] + !(sum[i] & 1);
        cnt[i][1] = cnt[i - 1][1] + (sum[i] & 1);
        ST[0][i] = i;
        //cout << num[i] << ' ';
    }
    for(int i = 0 ; i <= 64 ; ++i){
        int p = 0;
        for(int j = 1 ; j <= N ; ++j)
            while(p < j && sum[j] - sum[p] >= i << 1)
                rig[++p][i] = j;
        while(p < N)
            rig[++p][i] = N + 1;
        for(int j = N ; j ; --j)
            while(p >= j && sum[p] - sum[j - 1] >= i << 1)
                lef[p--][i] = j;
    }
    init_st();
    //cout << endl;
    solve(1 , N);
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>
#define ull unsigned long long
using namespace std;

inline ull read(){
    ull a = 0;
    char c = getchar();
    while(!isdigit(c))
        c = getchar();
    while(isdigit(c)){
        a = (a << 3) + (a << 1) + (c ^ '0');
        c = getchar();
    }
    return a;
}

const int MAXN = 3e5 + 10;
int num[MAXN] , rig[MAXN][65] , lef[MAXN][65] , cnt[MAXN][2] , sum[MAXN] , ST[21][MAXN] , logg2[MAXN] , N;
long long ans;

inline int cmp(int a , int b){
    return num[a] > num[b] ? a : b;
}

void init_st(){
    for(int i = 2 ; i <= N ; ++i)
        logg2[i] = logg2[i >> 1] + 1;
    for(int i = 1 ; 1 << i <= N ; ++i)
        for(int j = 1 ; j + (1 << i) - 1 <= N ; ++j)
            ST[i][j] = cmp(ST[i - 1][j] , ST[i - 1][j + (1 << (i - 1))]);
}

inline int query(int x , int y){
    int t = logg2[y - x + 1];
    return cmp(ST[t][x] , ST[t][y - (1 << t) + 1]);
}

void solve(int l , int r){
    if(l > r)
        return;
    if(l == r){
        ans += num[l] == 0;
        return;
    }
    int k = query(l , r);
    //cout << l << ' ' << r << ' ' << k << endl;
    solve(l , k - 1);
    solve(k + 1 , r);
    if(k - l < r - k)
        for(int i = k ; i >= l ; --i)
            ans += cnt[r][sum[i - 1] & 1] - cnt[min(max(k - 1 , rig[i][num[k]]) , r)][sum[i - 1] & 1];
    else
        for(int i = k ; i <= r ; ++i)
            if(lef[i][num[k]] >= l)
                ans += cnt[min(k - 1 , lef[i][num[k]] - 1)][sum[i] & 1] - (l == 1 ? 0 : cnt[l - 2][sum[i] & 1]);
    //cout << l << ' ' << r << ' ' << ans << endl;
}

int main(){
    N = read();
    cnt[0][0] = 1;
    for(int i = 1 ; i <= N ; ++i){
        ull a = read();
        while(a){
            if(a & 1)
                ++num[i];
            a >>= 1;
        }
        sum[i] = sum[i - 1] + num[i];
        cnt[i][0] = cnt[i - 1][0] + !(sum[i] & 1);
        cnt[i][1] = cnt[i - 1][1] + (sum[i] & 1);
        ST[0][i] = i;
        //cout << num[i] << ' ';
    }
    for(int i = 0 ; i <= 64 ; ++i){
        int p = 0;
        for(int j = 1 ; j <= N ; ++j)
            while(p < j && sum[j] - sum[p] >= i << 1)
                rig[++p][i] = j;
        while(p < N)
            rig[++p][i] = N + 1;
        for(int j = N ; j ; --j)
            while(p >= j && sum[p] - sum[j - 1] >= i << 1)
                lef[p--][i] = j;
    }
    init_st();
    //cout << endl;
    solve(1 , N);
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N=3e5+7;
int b[N],cnt[N][2],pre[N];
long long n;
void fio(long long &num)
{
	bool neg=0; num=0;
	register int c;
	c=getchar();
	if(c=='-') neg=1,c=getchar();
	for(;47<c && c<58;c=getchar()) num=num*10+c-'0';
	if(neg) num*=-1;
}

int main()
{
	//freopen("i.inp","r",stdin);
	fio(n);
	for(int i=1;i<=n;i++)
	{
		long long x;
		fio(x);
		b[i]=__builtin_popcountll(x);
	}
	cnt[1][0]=1-b[1]%2;
	cnt[1][1]=b[1]%2;
	pre[1]=b[1];
	for(int i=2;i<=n;i++)
	{
		if(b[i]%2) cnt[i][0]=cnt[i-1][1],cnt[i][1]=cnt[i-1][0]+1; else
		cnt[i][0]=cnt[i-1][0]+1,cnt[i][1]=cnt[i-1][1];
		pre[i]=pre[i-1]+b[i];
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		int mx=0,tmp=0;
		for(int j=i;j>=max(1,i-61);j--)
		{
			mx=max(mx,b[j]);
			int sum=pre[i]-pre[j-1]-mx;
			if((sum+mx)%2==0)
			{
				tmp++;
				ans+=(sum>=mx);
			}
		}
		ans+=(1LL*cnt[i][0]-tmp);
	}
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;

const int N=3e5+7;

void fastscan(long long &num)
{
	num=0;
	bool neg=false;
	register int c;
	c=getchar();
	if(c=='-') neg=true,c=getchar();
	for(;47<c && c<58;c=getchar()) num=num*10+c-'0';
	if(neg) num*=-1;
}

long long n;
int bit[N];
set<int> dp[N][61];

int main()
{
	//freopen("i.inp","r",stdin);
	fastscan(n);
	for(int i=1;i<=n;i++)
		{
			long long x;
			fastscan(x);
			bit[i]=__builtin_popcountll(x);
		}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		dp[i][bit[i]].insert(i);
		for(int k=0;k<=bit[i];k++)
			for(int j=bit[i]-2*k;j<=60;j++)
				for(int x: dp[i-1][j-(bit[i]-2*k)]) dp[i][j].insert(x);
		ans+=dp[i][0].size();
		if(i>2)
		for(int j=0;j<=60;j++) dp[i-2][j].clear();
	}
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;

const int N=3e5+7;

void fastscan(long long &num)
{
	num=0;
	bool neg=false;
	register int c;
	c=getchar();
	if(c=='-') neg=true,c=getchar();
	for(;47<c && c<58;c=getchar()) num=num*10+c-'0';
	if(neg) num*=-1;
}

long long n;
int bit[N];
vector<vector<set<int> > > dp;

int main()
{
	//freopen("i.inp","r",stdin);
	fastscan(n);
	dp.resize(n+1);
	for(int i=0;i<=n;i++) dp[i].resize(70);
	for(int i=1;i<=n;i++)
		{
			long long x;
			fastscan(x);
			bit[i]=__builtin_popcountll(x);
		}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		dp[i][bit[i]].insert(i);
		for(int k=0;k<=bit[i];k++)
			for(int j=bit[i]-2*k;j<=60;j++)
				for(int x: dp[i-1][j-(bit[i]-2*k)]) dp[i][j].insert(x);
		ans+=dp[i][0].size();
		if(i>2)
		for(int j=0;j<=60;j++) dp[i-2][j].clear();
	}
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;

const int N=1e4+7;

void fastscan(long long &num)
{
	num=0;
	bool neg=false;
	register int c;
	c=getchar();
	if(c=='-') neg=true,c=getchar();
	for(;47<c && c<58;c=getchar()) num=num*10+c-'0';
	if(neg) num*=-1;
}

long long n;
int bit[N];
set<int> dp[N][70];
int main()
{
	//freopen("i.inp","r",stdin);
	fastscan(n);
	for(int i=1;i<=n;i++)
		{
			long long x;
			fastscan(x);
			bit[i]=__builtin_popcountll(x);
		}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		dp[i][bit[i]].insert(i);
		for(int k=0;k<=bit[i];k++)
			for(int j=bit[i]-2*k;j<=60;j++)
				for(auto x: dp[i-1][j-(bit[i]-2*k)]) dp[i][j].insert(x);
		ans+=dp[i][0].size();
		if(i>2)
		for(int j=0;j<=60;j++) dp[i-2][j].clear();
	}
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;

const int N=3e5+7;
int b[N],cnt[N][2],pre[N];
long long n;
void fio(long long &num)
{
	bool neg=0; num=0;
	register int c;
	c=getchar();
	if(c=='-') neg=1,c=getchar();
	for(;47<c && c<58;c=getchar()) num=num*10+c-'0';
	if(neg) num*=-1;
}

int main()
{
	///freopen("i.inp","r",stdin);
	fio(n);
	for(int i=1;i<=n;i++)
	{
		long long x;
		fio(x);
		b[i]=__builtin_popcountll(x);
	}
	cnt[1][0]=1-b[1]%2;
	cnt[1][1]=b[1]%2;
	pre[1]=b[1];
	for(int i=2;i<=n;i++)
	{
		if(b[i]%2) cnt[i][0]=cnt[i-1][1],cnt[i][1]=cnt[i-1][0]+1; else
		cnt[i][0]=cnt[i-1][0]+1,cnt[i][1]=cnt[i-1][1];
		pre[i]=pre[i-1]+b[i];
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		int mx=0,tmp=0;
		for(int j=i;j>=max(1,i-61);j--)
		{
			mx=max(mx,b[j]);
			int sum=pre[i]-pre[j-1]-b[i];
			if((sum+b[i])%2==0)
			{
				tmp++;
				ans+=(sum>=mx);
			}
		}
		ans+=(1LL*cnt[i][0]-tmp);
	}
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;

const int N=3e5+7;

void fastscan(long long &num)
{
	num=0;
	bool neg=false;
	register int c;
	c=getchar();
	if(c=='-') neg=true,c=getchar();
	for(;47<c && c<58;c=getchar()) num=num*10+c-'0';
	if(neg) num*=-1;
}

long long n;
int bit[N];
set<int> dp[N][70];

int main()
{
	//freopen("i.inp","r",stdin);
	fastscan(n);
	for(int i=1;i<=n;i++)
		{
			long long x;
			fastscan(x);
			bit[i]=__builtin_popcountll(x);
		}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		dp[i][bit[i]].insert(i);
		for(int k=0;k<=bit[i];k++)
			for(int j=bit[i]-2*k;j<=60;j++)
				for(int x: dp[i-1][j-(bit[i]-2*k)]) dp[i][j].insert(x);
		ans+=dp[i][0].size();
		if(i>2)
		for(int j=0;j<=60;j++) dp[i-2][j].clear();
	}
	cout<<ans;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;

const int maxn = 300007;
int n, a[maxn], sum[maxn], odd[maxn], even[maxn];
ll Ans;

inline ll read(){
	bool f = false; ll val = 0; char ch = getchar();
	while ((ch < '0' || ch > '9') && (ch != '-')) ch = getchar();
	if (ch == '-') f = true, ch = getchar();
	while (ch >= '0' && ch <= '9') val = (val << 3) + (val << 1) + ch - '0', ch = getchar();
	return f ? (-val) : val;
}

int main(){
	n = read();
	sum[0] = 0;
	for (int i = 1; i <= n; ++i){
		ll x = read();
		a[i] = 0;
		for (int j = 0; j < 64; ++j)
			if ((x >> j) & 1) ++a[i];

		sum[i] = sum[i-1] + a[i];
	}

	odd[n+1] = even[n+1] = 0;
	for (int i = n; i >= 1; --i){
		odd[i] = odd[i+1] + (sum[i] % 2);
		even[i] = even[i+1] + (sum[i] % 2 == 0);
	}

	Ans = 0;

	for (int l = 1; l < n; ++l){
		int Max = a[l];
		for (int r = l + 1; r <= min(l + 60, n); ++r){
			Max = max(Max, a[r]);
			int Sum = sum[r] - sum[l-1];
			if (Sum % 2 == 0 && Max <= Sum / 2) ++Ans;
		}
		if (l + 61 <= n){
			if (sum[l-1] % 2 == 1) Ans += odd[l + 61];
			else Ans += even[l + 61];
		}
	}

	cout<<Ans<<endl;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;

const int maxn = 300007;
int n, a[maxn], sum[maxn], odd[maxn], even[maxn];
ll Ans;

inline ll read(){
	bool f = false; ll val = 0; char ch = getchar();
	while ((ch < '0' || ch > '9') && (ch != '-')) ch = getchar();
	if (ch == '-') f = true, ch = getchar();
	while (ch >= '0' && ch <= '9') val = (val << 3) + (val << 1) + ch - '0', ch = getchar();
	return f ? (-val) : val;
}

int main(){
	n = read();
	sum[0] = 0;
	for (int i = 1; i <= n; ++i){
		ll x = read();
		a[i] = 0;
		for (int j = 0; j < 64; ++j)
			if ((x >> j) & 1) ++a[i];

		sum[i] = sum[i-1] + a[i];
	}

	odd[n+1] = even[n+1] = 0;
	for (int i = n; i >= 1; --i){
		odd[i] = odd[i+1] + (sum[i] % 2);
		even[i] = even[i+1] + (sum[i] % 2 == 0);
	}

	Ans = 0;

	for (int l = 1; l < n; ++l){
		int Max = a[l];
		for (int r = l + 1; r <= min(l + 120, n); ++r){
			Max = max(Max, a[r]);
			int Sum = sum[r] - sum[l-1];
			if (Sum % 2 == 0 && Max <= Sum / 2) ++Ans;
		}
		if (l + 121 <= n){
			if (sum[l-1] % 2 == 1) Ans += odd[l + 121];
			else Ans += even[l + 121];
		}
	}

	cout<<Ans<<endl;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;

const int maxn = 300007;
int n, a[maxn], sum[maxn], odd[maxn], even[maxn];
ll Ans;

inline ll read(){
	bool f = false; ll val = 0; char ch = getchar();
	while ((ch < '0' || ch > '9') && (ch != '-')) ch = getchar();
	if (ch == '-') f = true, ch = getchar();
	while (ch >= '0' && ch <= '9') val = (val << 3) + (val << 1) + ch - '0', ch = getchar();
	return f ? (-val) : val;
}

int main(){
	n = read();
	sum[0] = 0;
	for (int i = 1; i <= n; ++i){
		ll x = read();
		a[i] = 0;
		for (int j = 0; j < 64; ++j)
			if ((x >> j) & 1) ++a[i];

		sum[i] = sum[i-1] + a[i];
	}

	odd[n+1] = even[n+1] = 0;
	for (int i = n; i >= 1; --i){
		odd[i] = odd[i+1] + (sum[i] % 2);
		even[i] = even[i+1] + (sum[i] % 2 == 0);
	}

	Ans = 0;

	for (int l = 1; l < n; ++l){
		int Max = a[l];
		for (int r = l + 1; r <= min(l + 61, n); ++r){
			Max = max(Max, a[r]);
			int Sum = sum[r] - sum[l-1];
			if (Sum % 2 == 0 && Max <= Sum / 2) ++Ans;
		}
		if (l + 62 <= n){
			if (sum[l] % 2 == 1) Ans += odd[l + 62];
			else Ans += even[l + 62];
		}
	}

	cout<<Ans<<endl;
	return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;

const int maxn = 300007;
int n, a[maxn], sum[maxn], odd[maxn], even[maxn];
ll Ans;

inline ll read(){
	bool f = false; ll val = 0; char ch = getchar();
	while ((ch < '0' || ch > '9') && (ch != '-')) ch = getchar();
	if (ch == '-') f = true, ch = getchar();
	while (ch >= '0' && ch <= '9') val = (val << 3) + (val << 1) + ch - '0', ch = getchar();
	return f ? (-val) : val;
}

int main(){
	n = read();
	sum[0] = 0;
	for (int i = 1; i <= n; ++i){
		ll x = read();
		a[i] = 0;
		for (int j = 0; j < 64; ++j)
			if ((x >> j) & 1) ++a[i];

		sum[i] = sum[i-1] + a[i];
	}

	odd[n+1] = even[n+1] = 0;
	for (int i = n; i >= 1; --i){
		odd[i] = odd[i+1] + (sum[i] % 2);
		even[i] = even[i+1] + (sum[i] % 2 == 0);
	}

	Ans = 0;

	for (int l = 1; l < n; ++l){
		int Max = a[l];
		for (int r = l + 1; r <= min(l + 120, n); ++r){
			Max = max(Max, a[r]);
			int Sum = sum[r] - sum[l-1];
			if (Sum % 2 == 0 && Max <= Sum / 2) ++Ans;
		}
		if (l + 121 <= n){
			if (sum[l] % 2 == 1) Ans += odd[l + 121];
			else Ans += even[l + 121];
		}
	}

	cout<<Ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
typedef long long ll;
char *p1,*p2,buf[100000];
#define nc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
int rd() {int x=0,f=1; char c=nc(); while(c<48) {if(c=='-') f=-1; c=nc();} while(c>47) x=(((x<<2)+x)<<1)+(c^48),c=nc(); return x*f;}
int n,a[310000];
ll bin[65];
int tree[2][250];
inline int lowbit(int x) {return x&(-x);}
void update(int x,int c,int opt){for(int i=x;i<=200;i+=lowbit(i))tree[opt][i]+=c;}
int query(int x,int opt){int ret=0;for(int i=x;i>=1;i-=lowbit(i))ret+=tree[opt][i];return ret;}
ll solve(int l,int r)
{
	if(l>=r)return 0;
	int mid=(l+r)/2;
	ll ret=0;int mx=0;
	int u=mid,u1=0,u2=0;
	for(int i=mid;i>=l;i--)
	{
		mx=max(mx,a[i]);u1+=a[i];
		while(a[u+1]<=mx&&u<r)
		{
			u2+=a[++u];int po=u2>200?200:u2;
			if(u2&1)update(po,1,1);
			else update(po,1,0);
		}
		ret+=((u1&1)?query(200,1)-query(max(2*mx-1-u1,0),1):query(200,0)-query(max(2*mx-1-u1,0),0));
	}
	u=mid+1,u1=u2=mx=0;
	memset(tree,0,sizeof tree);
	for(int i=mid+1;i<=r;i++)
	{
		mx=max(mx,a[i]);u1+=a[i];
		while(a[u-1]<mx&&u>l)
		{
			u2+=a[--u];int po=u2>200?200:u2;
			if(u2&1)update(po,1,1);
			else update(po,1,0);
		}
		ret+=((u1&1)?query(200,1)-query(max(2*mx-1-u1,0),1):query(200,0)-query(max(2*mx-1-u1,0),0));
	}
	memset(tree,0,sizeof tree);
	return ret+solve(l,mid)+solve(mid+1,r);
}
int main()
{
	bin[0]=1; for(int i=1;i<=62;i++)bin[i]=bin[i-1]<<1ll;
	n=rd();
	for(int i=1;i<=n;i++)
	{
		ll x=rd();
		for(int j=0;j<=62;j++)if(x&bin[j])a[i]++;
	}
	printf("%lld\n",solve(1,n));
	return 0;
}


#include<bits/stdc++.h>
#define N 300005
#define ll long long
using namespace std;
char *p1,*p2,buf[100000];
#define nc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
int rd() {int x=0,f=1; char c=nc(); while(c<48) {if(c=='-') f=-1; c=nc();} while(c>47) x=(((x<<2)+x)<<1)+(c^48),c=nc(); return x*f;}
int n;
ll a[N],sum[N],sum1[N],sum2[N],ans=0;
inline ll lowbit(ll x) {return x&-x;}
inline int calc(ll x)
{
	int re=0;
	while(x)x-=lowbit(x),++;
	return re;
}
int main()
{
	n=rd(),sum2[0]=1;
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+(a[i]=calc(rd()));
	for(int i=1;i<=n;++i)sum1[i]=sum1[i-1]+(sum[i]&1);
	for(int i=1;i<=n;++i)sum2[i]=sum2[i-1]+((sum[i]&1)^1);
	for(int r=1;r<=n;++r)
	{
		ll maxn=a[r];
		int low=max(1,r-64);
		for(int l=r;l>=low;--l)
		{
			maxn=max(maxn,a[l]);
			if((maxn<<1)<=(sum[r]-sum[l-1])&&(sum[r]&1)==(sum[l-1]&1))++ans;
		}
		if(low==1)continue;
		ans+=sum[r]&1?sum1[low-2]:sum2[low-2];
	}
	cout << ans << endl ;
	return 0;
}


#include<bits/stdc++.h>
#define N 300005
#define ll long long
using namespace std;
char *p1,*p2,buf[100000];
#define nc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
ll rd() {ll x=0,f=1; char c=nc(); while(c<48) {if(c=='-') f=-1; c=nc();} while(c>47) x=(((x<<2)+x)<<1)+(c^48),c=nc(); return x*f;}
int n;
ll a[N],sum[N],sum1[N],sum2[N],ans=0;
inline ll lowbit(ll x) {return x&-x;}
inline int calc(ll x)
{
	int re=0;
	while(x)x-=lowbit(x),re++;
	return re;
}
int main()
{
	n=rd(),sum2[0]=1;
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+(a[i]=calc(rd()));
	for(int i=1;i<=n;++i)sum1[i]=sum1[i-1]+(sum[i]&1);
	for(int i=1;i<=n;++i)sum2[i]=sum2[i-1]+((sum[i]&1)^1);
	for(int r=1;r<=n;++r)
	{
		ll maxn=a[r];
		int low=max(1,r-64);
		for(int l=r;l>=low;--l)
		{
			maxn=max(maxn,a[l]);
			if((maxn<<1)<=(sum[r]-sum[l-1])&&(sum[r]&1)==(sum[l-1]&1))++ans;
		}
		if(low==1)continue;
		ans+=sum[r]&1?sum1[low-2]:sum2[low-2];
	}
	cout << ans << endl ;
	return 0;
}


#include<bits/stdc++.h>
#define N 300005
#define ll long long
using namespace std;
char *p1,*p2,buf[100000];
#define nc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
int rd() {int x=0,f=1; char c=nc(); while(c<48) {if(c=='-') f=-1; c=nc();} while(c>47) x=(((x<<2)+x)<<1)+(c^48),c=nc(); return x*f;}
int n;
ll a[N],sum[N],sum1[N],sum2[N],ans=0;
inline ll lowbit(ll x) {return x&-x;}
inline int calc(ll x)
{
	int re=0;
	while(x)x-=lowbit(x),re++;
	return re;
}
int main()
{
	n=rd(),sum2[0]=1;
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+(a[i]=calc(rd()));
	for(int i=1;i<=n;++i)sum1[i]=sum1[i-1]+(sum[i]&1);
	for(int i=1;i<=n;++i)sum2[i]=sum2[i-1]+((sum[i]&1)^1);
	for(int r=1;r<=n;++r)
	{
		ll maxn=a[r];
		int low=max(1,r-64);
		for(int l=r;l>=low;--l)
		{
			maxn=max(maxn,a[l]);
			if((maxn<<1)<=(sum[r]-sum[l-1])&&(sum[r]&1)==(sum[l-1]&1))++ans;
		}
		if(low==1)continue;
		ans+=sum[r]&1?sum1[low-2]:sum2[low-2];
	}
	cout << ans << endl ;
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
using namespace std;
typedef long long ll;
char *p1,*p2,buf[100000];
#define nc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
int rd() {int x=0,f=1; char c=nc(); while(c<48) {if(c=='-') f=-1; c=nc();} while(c>47) x=(((x<<2)+x)<<1)+(c^48),c=nc(); return x*f;}
inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
inline void print(int x){write(x);printf(" ");}
int n,a[310000];
ll bin[65];
int tree[2][250];
inline int lowbit(int x) {return x&(-x);}
void update(int x,int c,int opt){for(int i=x;i<=200;i+=lowbit(i))tree[opt][i]+=c;}
int query(int x,int opt){int ret=0;for(int i=x;i>=1;i-=lowbit(i))ret+=tree[opt][i];return ret;}
ll solve(int l,int r)
{
	if(l>=r)return 0;
	int mid=(l+r)/2;
	ll ret=0;int mx=0;
	int u=mid,u1=0,u2=0;
	for(int i=mid;i>=l;i--)
	{
		mx=max(mx,a[i]);u1+=a[i];
		while(a[u+1]<=mx&&u<r)
		{
			u2+=a[++u];int po=u2>200?200:u2;
			if(u2&1)update(po,1,1);
			else update(po,1,0);
		}
		ret+=((u1&1)?query(200,1)-query(max(2*mx-1-u1,0),1):query(200,0)-query(max(2*mx-1-u1,0),0));
	}
	u=mid+1,u1=u2=mx=0;
	memset(tree,0,sizeof tree);
	for(int i=mid+1;i<=r;i++)
	{
		mx=max(mx,a[i]);u1+=a[i];
		while(a[u-1]<mx&&u>l)
		{
			u2+=a[--u];int po=u2>200?200:u2;
			if(u2&1)update(po,1,1);
			else update(po,1,0);
		}
		ret+=((u1&1)?query(200,1)-query(max(2*mx-1-u1,0),1):query(200,0)-query(max(2*mx-1-u1,0),0));
	}
	memset(tree,0,sizeof tree);
	return ret+solve(l,mid)+solve(mid+1,r);
}
int main()
{
	bin[0]=1;for(int i=1;i<=62;i++)bin[i]=bin[i-1]<<1LL;
	n=rd();
	for(int i=1;i<=n;i++)
	{
		ll x=rd();
		for(int j=0;j<=62;j++)if(x&bin[j])a[i]++;
	}
	printf("%lld\n",solve(1,n));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fast_io ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define erase_unique(x) (x).erase(unique(all(x)),(x).end())
#define sp(x) setprecision(x) << fixed
#define all(x) (x).begin(),(x).end()
#define cube(x) ((x)*(x)*(x))
#define sqr(x) ((x)*(x))
#define bg1 cout << '!'
#define bg2 cout << '?'
#define ln cout << '\n'
#define pb push_back
#define mp make_pair
#define endl '\n'
#define file_all file_in,file_out
#define file_in freopen("input.txt","rt",stdin)
#define file_out freopen("output.txt","wt",stdout)

const ll LLINF=8e18;
const int MOD=1e9+7;
const int INF=2e9;
const int N=3e5;

int n,cnt,c[2],tsum,tmax;
int a[N];
ll t,ans;

int get(ll t){
    int res=0;
    while(t>0){
        if (t%2==1) res++;
        t/=2;
    }
    return res;
}

int main(){
    fast_io;
    cin >> n;
    c[0]=1;
    for (int i=0; i<n; i++){
        cin >> t;
        a[i]=get(t);
        cnt+=a[i];
        ans+=c[cnt%2];
        c[cnt%2]++;
    }
    for (int i=0; i<n; i++){
        tmax=0;
        tsum=0;
        for (int j=i; j<min(n,i+61); j++){
            tmax=max(tmax,a[i]);
            tsum+=a[i];
            if (tsum%2==0&&tmax*2>tsum) ans--;
        }
    }
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fast_io ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define erase_unique(x) (x).erase(unique(all(x)),(x).end())
#define sp(x) setprecision(x) << fixed
#define all(x) (x).begin(),(x).end()
#define cube(x) ((x)*(x)*(x))
#define sqr(x) ((x)*(x))
#define bg1 cout << '!'
#define bg2 cout << '?'
#define ln cout << '\n'
#define pb push_back
#define mp make_pair
#define endl '\n'
#define file_all file_in,file_out
#define file_in freopen("input.txt","rt",stdin)
#define file_out freopen("output.txt","wt",stdout)

const ll LLINF=8e18;
const int MOD=1e9+7;
const int INF=2e9;
const int N=3e5;

int n,cnt,c[2];
int a[N];
ll t,ans;

int get(ll t){
    int res=0;
    while(t>0){
        if (t%2==1) res++;
        t/=2;
    }
    return res;
}

int main(){
    fast_io;
    cin >> n;
    c[0]=1;
    for (int i=0; i<n; i++){
        cin >> t;
        a[i]=get(t);
        if (a[i]%2==0) ans--;
        cnt+=a[i];
        ans+=c[cnt%2];
        c[cnt%2]++;
    }
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fast_io ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define erase_unique(x) (x).erase(unique(all(x)),(x).end())
#define sp(x) setprecision(x) << fixed
#define all(x) (x).begin(),(x).end()
#define cube(x) ((x)*(x)*(x))
#define sqr(x) ((x)*(x))
#define bg1 cout << '!'
#define bg2 cout << '?'
#define ln cout << '\n'
#define pb push_back
#define mp make_pair
#define endl '\n'
#define file_all file_in,file_out
#define file_in freopen("input.txt","rt",stdin)
#define file_out freopen("output.txt","wt",stdout)

const ll LLINF=8e18;
const int MOD=1e9+7;
const int INF=2e9;
const int N=3e5;

int n,cnt,c[2],tsum,tmax;
int a[N];
ll t,ans;

int get(ll t){
    int res=0;
    while(t>0){
        if (t%2==1) res++;
        t/=2;
    }
    return res;
}

int main(){
    fast_io;
    cin >> n;
    c[0]=1;
    for (int i=0; i<n; i++){
        cin >> t;
        a[i]=get(t);
        cnt+=a[i];
        ans+=c[cnt%2];
        c[cnt%2]++;
    }
    for (int i=0; i<n; i++){
        tmax=0;
        tsum=0;
        for (int j=i; j<min(n,i+60); j++){
            tmax=max(tmax,a[i]);
            tsum+=a[i];
            if (tsum%2==0&&tmax*2>tsum) ans--;
        }
    }
    cout << ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fast_io ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define erase_unique(x) (x).erase(unique(all(x)),(x).end())
#define sp(x) setprecision(x) << fixed
#define all(x) (x).begin(),(x).end()
#define cube(x) ((x)*(x)*(x))
#define sqr(x) ((x)*(x))
#define bg1 cout << '!'
#define bg2 cout << '?'
#define ln cout << '\n'
#define pb push_back
#define mp make_pair
#define endl '\n'
#define file_all file_in,file_out
#define file_in freopen("input.txt","rt",stdin)
#define file_out freopen("output.txt","wt",stdout)

const ll LLINF=8e18;
const int MOD=1e9+7;
const int INF=2e9;
const int N=3e5;

int n,cnt,c[2],tsum,tmax;
int a[N];
ll t,ans;

int get(ll t){
    int res=0;
    while(t>0){
        if (t%2==1) res++;
        t/=2;
    }
    return res;
}

int main(){
    fast_io;
    cin >> n;
    c[0]=1;
    for (int i=0; i<n; i++){
        cin >> t;
        a[i]=get(t);
        cnt+=a[i];
        ans+=c[cnt%2];
        c[cnt%2]++;
    }
    for (int i=0; i<n; i++){
        tmax=0;
        tsum=0;
        for (int j=i; j<min(n,i+60); j++){
            tmax=max(tmax,a[j]);
            tsum+=a[j];
            if (tsum%2==0&&tmax*2>tsum) ans--;
        }
    }
    cout << ans;
    return 0;
}


//Orz cyn2006
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mkp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define sz(v) (int)v.size()
typedef long long LL;
typedef double db;
template<class T>bool ckmax(T&x,T y){return x<y?x=y,1:0;}
template<class T>bool ckmin(T&x,T y){return x>y?x=y,1:0;}
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define per(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f?x:-x;
}
const int N=300005;
int n,c[N],cnt[2],s[N];
LL ans;
signed main(){
	scanf("%d",&n);
	rep(i,1,n){
		LL x;scanf("%lld",&x);
		while(x)x^=x&-x,++c[i];
		s[i]=s[i-1]^(c[i]&1);
	}
	rep(i,1,n){
		int mx=0,sum=0;
		per(j,i,max(i-63,1)){
			ckmax(mx,c[j]),sum+=c[j];
			if(mx*2<=sum&&s[j-1]==s[i])++ans;
		}
		if(i>=63)ans+=cnt[s[i]],++cnt[s[i-63]];
	}
	printf("%lld\n",ans);
	return 0;
}


//Orz cyn2006
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mkp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define sz(v) (int)v.size()
typedef long long LL;
typedef double db;
template<class T>bool ckmax(T&x,T y){return x<y?x=y,1:0;}
template<class T>bool ckmin(T&x,T y){return x>y?x=y,1:0;}
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define per(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f?x:-x;
}
const int N=300005;
int n,c[N],cnt[2],s[N];
LL ans;
signed main(){
	scanf("%d",&n);
	rep(i,1,n){
		LL x;scanf("%lld",&x);
		while(x)x^=x&-x,++c[i];
		s[i]=s[i-1]^(c[i]&1);
	}
	rep(i,1,n){
		int mx=0,sum=0;
		per(j,i,max(i-63,1)){
			ckmax(mx,c[j]),sum+=c[j];
			if(mx*2<=sum&&s[j-1]==s[i])++ans;
		}
		if(i>=64)ans+=cnt[s[i]],++cnt[s[i-64]];
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define sz 301010
#define mod 2147483648ll
using namespace std;
typedef long long ll;
struct FastIO
{
    inline FastIO& operator>>(int& x)
    {
        x=0;char f=0,ch=getchar();
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
        return x=(f?-x:x),*this;
    }
    inline FastIO& operator>>(ll& x)
    {
        x=0;char f=0,ch=getchar();
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
        return x=(f?-x:x),*this;
    }
    inline FastIO& operator>>(double& x)
    {
        x=0;char f=0,ch=getchar();
        double d=0.1;
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') x=x*10+ch-48,ch=getchar();
        if(ch=='.')
        {
            ch=getchar();
            while(ch<='9'&&ch>='0') x+=d*(ch^48),d*=0.1,ch=getchar();
        }
        return x=(f?-x:x),*this;
    }
}read;
void file()
{
    #ifndef ONLINE_JUDGE
    freopen("a.txt","r",stdin);
    #endif
}
unsigned int log2(int x){unsigned int ret;__asm__ __volatile__ ("bsrl %1, %%eax":"=a"(ret):"m"(x));return ret;}
inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
int cnt[sz];
int sum[sz];
int n;
int count(ll x)
{
	int ret=0;
	while (x) ret++,x-=(x&(-x));
	return ret;
}
int main()
{
	file();
	int i,j,k,x,y;
	ll z;
	read>>n;
	for (i=1;i<=n;i++) read>>z,sum[i]=sum[i-1]+(cnt[i]=count(z));
	ll ans=0,odd=0,even=1;
	for (i=1;i<=n;i++)
	{
		(sum[i]&1)?ans+=odd++:ans+=even++;
		if ((sum[i]-sum[i-1])%2==0) ans--;
	}
	for (i=1;i<=n;i++)
	{
		int s=cnt[i],mx=cnt[i];
		for (j=i-1;i-j<=61&&j;j--)
		{
			s+=cnt[i];mx=max(mx,cnt[j]);
			if (mx>s-mx) --ans;
		}
	}
	cout<<ans;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long

inline int getint(){
	int ssum=0,ff=1;char ch;
	for(ch=getchar();!isdigit(ch)&&ch!='-';ch=getchar());
	if(ch=='-') ff=-1,ch=getchar();
	for(;isdigit(ch);ch=getchar()) ssum=ssum*10+ch-'0';
	return ssum*ff;
}

const int M=5e5+5;

int s0[M],s1[M],ans,a[M],s[M],n;

signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x=getint();
		while(x){if(x&1) a[i]++;x>>=1;}
		a[i]&=1;
	}
	for(int i=1;i<=n;i++) s0[i]=s0[i-1]+(a[i]%2==0);
	for(int i=1;i<=n;i++) s1[i]=s1[i-1]+(a[i]&1);
	for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i];

	int ans=0;
	for(int i=1;i<=n;i++){
		int L=max(1ll,i-100),sum=0,mx=0;
		for(int j=i;j>=L;j--){
			sum+=a[j];mx=max(mx,a[j]);
			if(sum%2==0&&sum>=mx*2) ans++;
		}
		int now=s[i]-s[L-1];now&=1;
		if(now){
			if(s[L-1]&1){
				ans+=s0[L-1];
			}
			else{
				ans+=s1[L-1];
			}
		}
		else{
			if(s[L-1]&1){
				ans+=s1[L-1];
			}
			else{
				ans+=s0[L-1];
			}
		}
	}

	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long

inline int getint(){
	int ssum=0,ff=1;char ch;
	for(ch=getchar();!isdigit(ch)&&ch!='-';ch=getchar());
	if(ch=='-') ff=-1,ch=getchar();
	for(;isdigit(ch);ch=getchar()) ssum=ssum*10+ch-'0';
	return ssum*ff;
}

const int M=5e5+5;

int s0[M],s1[M],ans,a[M],s[M],n;

signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int x=getint();
		while(x){if(x&1) a[i]++;x>>=1;}
	}
	s0[0]=1;
	for(int i=1;i<=n;i++) s[i]=s[i-1]+(a[i]%2);
	for(int i=1;i<=n;i++) s0[i]=s0[i-1]+(s[i]%2==0);
	for(int i=1;i<=n;i++) s1[i]=s1[i-1]+(s[i]&1);

//	for(int i=1;i<=n;i++) cout<<a[i]<<" ";cout<<endl;
//	for(int i=1;i<=n;i++) cout<<i<<" "<<s[i]<<" "<<s0[i]<<" "<<s1[i]<<endl;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(s[i]&1){
			ans+=s1[i-1];
		}
		else{
			ans+=s0[i-1];
		}
	//	cout<<"pre "<<ans<<endl;
		int L=max(1ll,i-64),sum=0,mx=0;
		for(int j=i;j>=L;j--){
			sum+=a[j];mx=max(mx,a[j]);
			if(sum%2==0&&sum<mx*2) ans--;
		}//cout<<ans<<endl;
	}

	cout<<ans<<endl;
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

int cnt[300], m[300];

int32_t main() { _
	int n;
	string s;
	cin >> n >> s;
	vector<char> chs, evens;
	for (int i = 0; i < n; ++i) {
		++m[s[i]];
		chs.push_back(s[i]);
	}
	sort(chs.begin(), chs.end());
	chs.resize(unique(chs.begin(), chs.end()) - chs.begin());
	vector<string> ans;

	int sth = 0;
	for (auto ch: chs) {
		if (m[ch] & 1) {
			string sr;
			sr += ch;
			ans.push_back(sr);
			--m[ch];
		} else {
			sth += m[ch];
			evens.push_back(ch);
		}
	}
	if (ans.size() == 0) {
		string str;
		for (auto ch: chs) {
			if (m[ch] > 0) {
				int j = 1;
				while (j * 2 <= m[ch]) {
					str = ch + str + ch;
					++j;
				}
			}
		}
		cout << "1\n" << str << endl;
		return 0;
	}
	if (sth % ans.size() != 0) {
		cout << s.length() << '\n';
		for (auto i: s)
			cout << i << ' ';
		cout << endl;
		return 0;
	}
	sth /= ans.size();
	cout << ans.size() << '\n';
	auto ptr = evens.begin();
	for (int i = 0; i < ans.size(); ++i) {
		string all;
		int C = 0;
		while (C < sth) {
			while (C < sth and cnt[*ptr] < m[*ptr]) {
				cnt[i] += 2;
				C += 2;
				all += *ptr;
			}
			++ptr;
		}
		string rev = all;
		reverse(all.begin(), all.end());
		cout << rev << ans[i] << all << ' ';
	}
	cout << '\n';
}


#include "bits/stdc++.h"

using namespace std;

#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

int cnt[300], m[300];

int32_t main() { _
	int n;
	string s;
	cin >> n >> s;
	vector<char> chs;
	for (int i = 0; i < n; ++i) {
		++m[s[i]];
		chs.push_back(s[i]);
	}
	sort(chs.begin(), chs.end());
	chs.resize(unique(chs.begin(), chs.end()) - chs.begin());
	vector<string> ans;

	int sth = 0;
	for (auto ch: chs) {
		pair<char, int> i {ch, m[ch]};
		if (i.second & 1) {
			string sr;
			sr += i.first;
			ans.push_back(sr);
			--m[ch];
		} else {
			sth += i.second;
		}
	}
	if (ans.size() == 0) {
		string str;
		for (auto ch: chs) {
			pair<char, int> i {ch, m[ch]};
			if (i.second > 0) {
				int j = 1;
				while (j * 2 <= i.second) {
					str = i.first + str + i.first;
					++j;
				}
			}
		}
		cout << "1\n" << str << endl;
		return 0;
	}
	if (sth % ans.size() != 0) {
		cout << s.length() << '\n';
		for (auto i: s)
			cout << i << ' ';
		cout << endl;
		return 0;
	}
	sth /= ans.size();
	int ptr = 0;
	for (auto ch: chs) {
		pair<char, int> i {ch, m[ch]};
		if (i.second > 0) {
			int j = 1;
			while (j * 2 <= i.second) {
				while (cnt[ptr] < sth) {
					string bck;
					if (j * 2 <= i.second) {
						cnt[ptr] += 2;
						ans[ptr] += i.first;
						bck += i.first;
						++j;
					} else break;
					ans[ptr] = bck + ans[ptr];
				}
				if (cnt[ptr] == sth)
					++ptr;
			}
		}
	}

	cout << ans.size() << '\n';
	for (auto i: ans)
		cout << i << ' ';
	cout << endl;
}


#include "bits/stdc++.h"

using namespace std;

#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

int cnt[300], m[300];

int32_t main() { _
	int n;
	string s;
	cin >> n >> s;
	vector<char> chs, evens;
	for (int i = 0; i < n; ++i) {
		++m[s[i]];
		chs.push_back(s[i]);
	}
	sort(chs.begin(), chs.end());
	chs.resize(unique(chs.begin(), chs.end()) - chs.begin());
	vector<string> ans;

	int sth = 0;
	for (auto ch: chs) {
		if (m[ch] & 1) {
			string sr;
			sr += ch;
			ans.push_back(sr);
			--m[ch];
			if (m[ch] > 0) {
				m[ch] /= 2;
				sth += m[ch];
				evens.push_back(ch);
			}
		} else {
			m[ch] /= 2;
			sth += m[ch];
			evens.push_back(ch);
		}
	}
	if (ans.size() == 0) {
		string str;
		for (auto ch: chs) {
			if (m[ch] > 0) {
				int j = 1;
				while (j * 2 <= m[ch]) {
					str = ch + str + ch;
					++j;
				}
			}
		}
		cout << "1\n" << str << endl;
		return 0;
	}
	if (sth % ans.size() != 0) {
		cout << s.length() << '\n';
		for (auto i: s)
			cout << i << ' ';
		cout << endl;
		return 0;
	}
	sth /= ans.size();
	cout << ans.size() << '\n';
	auto ptr = evens.begin();
	for (int i = 0; i < ans.size(); ++i) {
		string all;
		int C = 0;
		while (C < sth) {
			while (C < sth and cnt[*ptr] < m[*ptr]) {
				++cnt[*ptr];
				++C;
				all += *ptr;
			}
			if (C < sth) ++ptr;
		}
		string rev = all;
		reverse(all.begin(), all.end());
		cout << rev << ans[i] << all << ' ';
	}
	cout << '\n';
}