#include<bits/stdc++.h>
#define int long long
using namespace std;
 main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {cin>>a[i];
    int x=0;
    while(a[i]>0)
    {
        if(a[i]%2==1)
            x++;
        a[i]/=2;
    }

    a[i]=x;
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int y=0,maxi=0;
        for(int j=i;j<min(n,i+70);j++)
        {
            y+=a[j];
            maxi=max(maxi,a[j]);
            if(maxi*2<=y&&y%2==0)
                sum++;

        }
    }
    vector<int>b(n);
    vector<int>c(n);
    for(int i=n-1;i>=0;i--)
    {
        if(i==n-1)
        {
            if(a[i]%2==0)
                b[i]++;
            else c[i]++;
        }
        else

        {
            if(a[i]%2==0)
            {
                b[i]=b[i+1]+1;
                c[i]=c[i+1];
            }
            else
            {
                b[i]=c[i];
                c[i]=b[i]+1;
            }

        }
    }
    for(int i=0;i<n-70;i++)
    {
        int x=0;
        for(int j=i;j<i+70;j++)
            x+=a[j];
        if(x%2==0)
            sum+=b[i+70];
        else sum+=c[i+70];
    }
    cout<<sum;

}


#include<bits/stdc++.h>
#define int long long
using namespace std;
 main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {cin>>a[i];
    int x=0;
    while(a[i]>0)
    {
        if(a[i]%2==1)
            x++;
        a[i]/=2;
    }

    a[i]=x;
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int y=0,maxi=0;
        for(int j=i;j<min(n,i+70);j++)
        {
            y+=a[j];
            maxi=max(maxi,a[j]);
            if(maxi*2<=y&&y%2==0)
                sum++;

        }
    }
    vector<int>b(n);
    vector<int>c(n);
    for(int i=n-1;i>=0;i--)
    {
        if(i==n-1)
        {
            if(a[i]%2==0)
                b[i]++;
            else c[i]++;
        }
        else

        {
            if(a[i]%2==0)
            {
                b[i]=b[i+1]+1;
                c[i]=c[i+1];
            }
            else
            {
                b[i]=c[i];
                c[i]=b[i]+1;
            }

        }
    }
    for(int i=0;i<n-70;i++)
    {
        int x=0;
        for(int j=i;j<i+70;j++)
            x+=a[i];
        if(x%2==0)
            sum+=b[i+70];
        else sum+=c[i+70];
    }
    cout<<sum;

}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
#define int long long
int n,a[maxn],ans;
int c[2],pre[maxn];
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		a[i]=__builtin_popcountll(x);
	}
	c[0]++;
	for(int i=1;i<=n;i++)
	{
		pre[i]=pre[i-1]+a[i];
		ans+=c[pre[i]%2];
		c[pre[i]%2]++;
	}
	for(int i=1;i<=n;i++)
	{
		int mx=0,sum=0;
		for(int j=i;j<=n&&j-i<=61;j++)
		{
			mx=max(mx,a[j]);sum+=a[j];
			if(mx>sum-mx&&sum%2==0)ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
#define int long long
int n,a[maxn],ans;
int c[2],pre[maxn];
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		a[i]=__builtin_popcountll(x);
	}
	c[0]++;
	for(int i=1;i<=n;i++)
	{
		pre[i]=pre[i-1]+a[i];
		ans+=c[pre[i]%2];
		c[pre[i]%2]++;
	}
	for(int i=1;i<=n;i++)
	{
		int mx=0,sum=0;
		for(int j=i;j<=n&&sum<=128;j++)
		{
			mx=max(mx,a[i]);sum+=a[i];
			if(mx>sum-mx&&sum%2==0)ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
#define int long long
int n,a[maxn],ans;
int c[2],pre[maxn];
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		a[i]=__builtin_popcountll(x);
	}
	c[0]++;
	for(int i=1;i<=n;i++)
	{
		pre[i]=pre[i-1]+a[i];
		ans+=c[pre[i]%2];
		c[pre[i]%2]++;
	}
	for(int i=1;i<=n;i++)
	{
		int mx=0,sum=0;
		for(int j=i;j<=n&&j-i<65;j++)
		{
			mx=max(mx,a[j]);sum+=a[j];
			if(mx>sum-mx&&sum%2==0)ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
#define int long long
int n,a[maxn],ans;
int c[2],pre[maxn];
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		a[i]=__builtin_popcountll(x);
	}
	c[0]++;
	for(int i=1;i<=n;i++)
	{
		pre[i]=pre[i-1]+a[i];
		ans+=c[pre[i]%2];
		c[pre[i]%2]++;
	}
	for(int i=1;i<=n;i++)
	{
		int mx=0,sum=0;
		for(int j=i;j<=n&&j-i<=60;j++)
		{
			mx=max(mx,a[j]);sum+=a[j];
			if(mx>sum-mx&&sum%2==0)ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
#define int long long
int n,a[maxn],ans;
int c[2],pre[maxn];
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		a[i]=__builtin_popcountll(x);
	}
	c[0]++;
	for(int i=1;i<=n;i++)
	{
		pre[i]=pre[i-1]+a[i];
		ans+=c[pre[i]%2];
		c[pre[i]%2]++;
	}
	for(int i=1;i<=n;i++)
	{
		int mx=0,sum=0;
		for(int j=i;j<=n&&sum<124;j++)
		{
			mx=max(mx,a[i]);sum+=a[i];
			if(mx>sum-mx&&sum%2==0)ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <cstdlib>
#include <unordered_set>
#include <bitset>

using namespace std;

#define INF 1000000010
#define MOD 1000000007
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define pii pair <int, int>

const long long MAXN = 1e6 + 10;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;

int n, a[MAXN], b[MAXN], sum[MAXN];
ll x, ans;

int cnt(){
    int res = 0;
    while(x > 0){
        res += x % 2;
        x /= 2;
    }
    return res;
}

ll calc(int l){
    int maxx = a[l], res = 0;
    for(int i = l + 1; i < min(n, l + 65); i++){
        maxx = max(maxx, a[i]);
        int h = sum[i];
        if(l - 1 >= 0)
            h -= sum[l - 1];
       // if(l == 3){
         //   cerr << maxx << ' ' << h << endl;
        //}
        if(h % 2 == 0 && maxx > h / 2)
            res++;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("anagrams2.in", "r", stdin);
    //freopen("anagrams2.out", "w", stdout);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        a[i] = cnt();
    }
    b[0] = a[0] % 2;
    sum[0] = a[0];
    for(int i = 1; i < n; i++){
        b[i] = (b[i - 1] + a[i]) % 2;
        sum[i] = sum[i - 1] + a[i];
    }
   /* for(int i = 0; i < n; i++){
        cerr << a[i] << ' ' << b[i] << ' ' << sum[i] << endl;
    }
    cerr << endl;*/
    int odd = 0, even = 0;
    b[n - 1] == 0 ? even++ : odd++;
    for(int i = n - 2; i >= 0; i--){
        ll cur;
        if(i - 1 >= 0){
            b[i - 1] == 0 ? cur = even : cur = odd;
        }
        else
            cur = even;
        cur -= calc(i);
       // cerr << cur << endl;
        ans += cur;
        b[i] == 0 ? even++ : odd++;
    }
    cout << ans;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <cstdlib>
#include <unordered_set>
#include <bitset>

using namespace std;

#define INF 1000000010
#define MOD 1000000007
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define pii pair <int, int>

const long long MAXN = 1e6 + 10;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;

int n, a[MAXN], b[MAXN], sum[MAXN];
ll x, ans;

int cnt(){
    int res = 0;
    while(x > 0){
        res += x % 2;
        x /= 2;
    }
    return res;
}

ll calc(int l){
    int maxx = a[l], res = 0;
    for(int i = l + 1; i < min(n, l + 65); i++){
        maxx = max(maxx, a[l]);
        int h = sum[i];
        if(l - 1 >= 0)
            h -= sum[l - 1];
        if(h % 2 == 0 && maxx > h / 2)
            res++;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("anagrams2.in", "r", stdin);
    //freopen("anagrams2.out", "w", stdout);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        a[i] = cnt();
    }
    b[0] = a[0] % 2;
    sum[0] = b[0];
    for(int i = 1; i < n; i++){
        b[i] = (b[i - 1] + a[i]) % 2;
        sum[i] = sum[i - 1] + a[i];
    }
    int odd = 0, even = 0;
    b[n - 1] == 0 ? even++ : odd++;
    for(int i = n - 2; i >= 0; i--){
        ll cur;
        if(i - 1 >= 0){
            b[i - 1] == 0 ? cur = even : cur = odd;
        }
        else
            cur = even;
        cur -= calc(i);
        //cerr << cur << endl;
        ans += cur;
        b[i] == 0 ? even++ : odd++;
    }
    cout << ans;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <cstdlib>
#include <unordered_set>
#include <bitset>

using namespace std;

#define INF 1000000010
#define MOD 1000000007
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define pii pair <int, int>

const long long MAXN = 1e6 + 10;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;

int n, a[MAXN], b[MAXN], sum[MAXN];
ll x, ans;

int cnt(){
    int res = 0;
    while(x > 0){
        res += x % 2;
        x /= 2;
    }
    return res;
}

ll calc(int l){
    int maxx = a[l], res = 0;
    for(int i = l + 1; i < min(n, l + 65); i++){
        maxx = max(maxx, a[l]);
        int h = sum[i];
        if(l - 1 >= 0)
            h -= sum[l - 1];
        if(h % 2 == 0 && maxx > h / 2)
            res++;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("anagrams2.in", "r", stdin);
    //freopen("anagrams2.out", "w", stdout);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        a[i] = cnt();
    }
    b[0] = a[0] % 2;
    sum[0] = a[0];
    for(int i = 1; i < n; i++){
        b[i] = (b[i - 1] + a[i]) % 2;
        sum[i] = sum[i - 1] + a[i];
    }
    int odd = 0, even = 0;
    b[n - 1] == 0 ? even++ : odd++;
    for(int i = n - 2; i >= 0; i--){
        ll cur;
        if(i - 1 >= 0){
            b[i - 1] == 0 ? cur = even : cur = odd;
        }
        else
            cur = even;
        cur -= calc(i);
        //cerr << cur << endl;
        ans += cur;
        b[i] == 0 ? even++ : odd++;
    }
    cout << ans;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <cstdlib>
#include <unordered_set>
#include <bitset>

using namespace std;

#define INF 1000000010
#define MOD 1000000007
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define pii pair <int, int>

const long long MAXN = 1e6 + 10;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector <int> vi;

ll n, a[MAXN], b[MAXN], sum[MAXN];
ll x, ans;

ll cnt(){
    ll res = 0;
    while(x > 0){
        res += x % 2;
        x /= 2;
    }
    return res;
}

ll calc(ll l){
    ll maxx = a[l], res = 0;
    for(int i = l + 1; i < min(n, l + 65); i++){
        maxx = max(maxx, a[l]);
        ll h = sum[i];
        if(l - 1 >= 0)
            h -= sum[l - 1];
        if(h % 2 == 0 && maxx > h / 2)
            res++;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("anagrams2.in", "r", stdin);
    //freopen("anagrams2.out", "w", stdout);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x;
        a[i] = cnt();
    }
    b[0] = a[0] % 2;
    sum[0] = b[0];
    for(int i = 1; i < n; i++){
        b[i] = (b[i - 1] + a[i]) % 2;
        sum[i] = sum[i - 1] + a[i];
    }
    ll odd = 0, even = 0;
    b[n - 1] == 0 ? even++ : odd++;
    for(int i = n - 2; i >= 0; i--){
        ll cur;
        if(i - 1 >= 0){
            b[i - 1] == 0 ? cur = even : cur = odd;
        }
        else
            cur = even;
        cur -= calc(i);
        //cerr << cur << endl;
        ans += cur;
        b[i] == 0 ? even++ : odd++;
    }
    cout << ans;

    return 0;
}


#include <iostream>
#include <random>
#include <chrono>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) { x += y;if (x >= MOD) return x - MOD;return x; }
ll sub(ll x, ll y) { x -= y;if (x < 0) return x + MOD;return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5+5;

ll a[N], sum[N], cnt_even[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) cin >> a[i];

    for (ll i = n-1; i >= 0; --i) {
        sum[i] = __builtin_popcountll(a[i]) + sum[i+1];
        cnt_even[i] = !(a[i] & 1) + cnt_even[i+1];
    }

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

    for (ll i = 0; i < n-1; ++i) {
        ll cum = __builtin_popcountll(a[i]);
        ll maxx = cum;
        for (ll j = i+1; j < n && j-i <= 65; ++j) {
            cum += __builtin_popcountll(a[j]);
            maxx = max(maxx, (ll)__builtin_popcountll(a[j]));
            if (cum-maxx >= maxx) break;
            if (!((a[j]-a[i]) & 1)) ans -= 1;
        }
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <random>
#include <chrono>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) { x += y;if (x >= MOD) return x - MOD;return x; }
ll sub(ll x, ll y) { x -= y;if (x < 0) return x + MOD;return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5+5;

ll a[N], sum[N], cnt_even[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) cin >> a[i];

    for (ll i = n-1; i >= 0; --i) {
        sum[i] = __builtin_popcountll(a[i]) + sum[i+1];
        cnt_even[i] = !(__builtin_popcountll(a[i]) & 1) + cnt_even[i+1];
    }

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

    for (ll i = 0; i < n; ++i) {
        ll cnt_left = __builtin_popcountll(a[i]);
        ll cum = cnt_left;
        ll maxx = cum;
        for (ll j = i+1; j < n && j-i <= 65; ++j) {
            ll cnt_right = __builtin_popcountll(a[j]);
            cum += cnt_right;
            maxx = max(maxx, cnt_right);
            if (cum-maxx >= maxx) break;
            if (!((cnt_right-cnt_left) & 1)) ans -= 1;
        }
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <random>
#include <chrono>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) { x += y;if (x >= MOD) return x - MOD;return x; }
ll sub(ll x, ll y) { x -= y;if (x < 0) return x + MOD;return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5+5;

ll a[N], sum[N], cnt_even[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) cin >> a[i];

    for (ll i = n-1; i >= 0; --i) {
        sum[i] = a[i] + sum[i+1];
        cnt_even[i] = !(a[i] & 1) + cnt_even[i+1];
    }

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

    for (ll i = 0; i < n; ++i) {
        ll cum = a[i];
        ll maxx = cum;
        for (ll j = i+1; j < n && j-i <= 65; ++j) {
            cum += a[j];
            maxx = max(maxx, a[j]);
            if (cum-maxx >= maxx) break;
            if (!((a[j]-a[i]) & 1)) ans -= 1;
        }
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <random>
#include <chrono>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) { x += y;if (x >= MOD) return x - MOD;return x; }
ll sub(ll x, ll y) { x -= y;if (x < 0) return x + MOD;return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5+5;

ll a[N], sum[N], cnt_even[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) cin >> a[i];

    for (ll i = n-2; i >= 0; --i) {
        sum[i] = a[i] + sum[i+1];
        cnt_even[i] = !(a[i] & 1) + cnt_even[i+1];
    }

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

    for (ll i = 0; i < n; ++i) {
        ll cum = a[i];
        ll maxx = cum;
        for (ll j = i+1; j < n && j-i <= 65; ++j) {
            cum += a[j];
            maxx = max(maxx, a[j]);
            if (cum-maxx >= maxx) break;
            if (!((a[j]-a[i]) & 1)) ans -= 1;
        }
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <random>
#include <chrono>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) { x += y;if (x >= MOD) return x - MOD;return x; }
ll sub(ll x, ll y) { x -= y;if (x < 0) return x + MOD;return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5+5;

ll a[N], sum[N], cnt_even[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) cin >> a[i];

    for (ll i = n-1; i >= 0; --i) {
        sum[i] = a[i] + sum[i+1];
        cnt_even[i] = !(a[i] & 1) + cnt_even[i+1];
    }

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

    for (ll i = 0; i < n-1; ++i) {
        ll cum = __builtin_popcountll(a[i]);
        ll maxx = cum;
        for (ll j = i+1; j < n && j-i <= 65; ++j) {
            cum += __builtin_popcountll(a[j]);
            maxx = max(maxx, (ll)__builtin_popcountll(a[j]));
            if (cum-maxx >= maxx) break;
            if (!((a[j]-a[i]) & 1)) ans -= 1;
        }
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <random>
#include <chrono>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) { x += y;if (x >= MOD) return x - MOD;return x; }
ll sub(ll x, ll y) { x -= y;if (x < 0) return x + MOD;return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5+5;

ll a[N], sum[N], cnt_even[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
        a[i] = __builtin_popcountll(a[i]);
    }

    cnt_even[n] = 1;
    for (ll i = n-1; i >= 0; --i) {
        sum[i] = a[i] + sum[i+1];
        cnt_even[i] = !(sum[i] & 1) + cnt_even[i+1];
    }

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

    for (ll i = 0; i < n-1; ++i) {
        ll cum = a[i];
        ll maxx = a[i];
        for (ll j = i+1; j < n && j-i <= 65; ++j) {
            cum += a[j];
            maxx = max(maxx, a[j]);
            if (cum-maxx < maxx && !(cum & 1)) --ans;
        }
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <random>
#include <chrono>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) { x += y;if (x >= MOD) return x - MOD;return x; }
ll sub(ll x, ll y) { x -= y;if (x < 0) return x + MOD;return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5+5;

ll a[N], sum[N], cnt_even[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) cin >> a[i];

    for (ll i = n-1; i >= 0; --i) {
        sum[i] = a[i] + sum[i+1];
        cnt_even[i] = !(a[i] & 1) + cnt_even[i+1];
    }

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

    for (ll i = 0; i < n; ++i) {
        int cum = 0;
        for (ll j = i+1; j < n && j-i <= 65; ++j) {
            cum += sum[i]-sum[i+1];
            if (cum >= a[i]) break;
            if (!((a[j]-a[i]) & 1)) ans -= 1;
        }
    }

    cout << ans-1 << endl;

    return 0;
}


#include <iostream>
#include <random>
#include <chrono>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) { x += y;if (x >= MOD) return x - MOD;return x; }
ll sub(ll x, ll y) { x -= y;if (x < 0) return x + MOD;return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5+5;

ll a[N], sum[N], cnt_even[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
        a[i] = __builtin_popcountll(a[i]);
    }

    cnt_even[n] = 1;
    for (ll i = n-1; i >= 0; --i) {
        sum[i] = a[i] + sum[i+1];
        cnt_even[i] = !(a[i] & 1) + cnt_even[i+1];
    }

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

    for (ll i = 0; i < n-1; ++i) {
        ll cum = a[i];
        ll maxx = a[i];
        for (ll j = i+1; j < n && j-i <= 65; ++j) {
            cum += a[j];
            maxx = max(maxx, a[j]);
            if (cum-maxx >= maxx) break;
            if (!(cum & 1)) ans -= 1;
        }
    }

    cout << ans << endl;

    return 0;
}


#include <iostream>
#include <random>
#include <chrono>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) { x += y;if (x >= MOD) return x - MOD;return x; }
ll sub(ll x, ll y) { x -= y;if (x < 0) return x + MOD;return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 3e5+5;

ll a[N], sum[N], cnt_even[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) {
        cin >> a[i];
        a[i] = __builtin_popcountll(a[i]);
    }

    cnt_even[n] = 1;
    for (ll i = n-1; i >= 0; --i) {
        sum[i] = a[i] + sum[i+1];
        cnt_even[i] = !(a[i] & 1) + cnt_even[i+1];
    }

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

    for (ll i = 0; i < n-1; ++i) {
        ll cum = a[i];
        ll maxx = a[i];
        for (ll j = i+1; j < n && j-i <= 65; ++j) {
            cum += a[j];
            maxx = max(maxx, a[j]);
            if (cum-maxx < maxx && !(cum & 1)) --ans;
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

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

const int MAXN = 3e5+5;

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

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

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

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


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

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

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

const int MAXN = 3e5+5;

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

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

    for (int i = 1; i <= N; i++) {
        psum[i] = psum[i - 1] + in[i];
    }
    // REP(i, N + 1) {
    //     cout << psum[i] << " ";
    // }
    // cout << endl;
    // REP(i, N + 1) {
    //     cout << in[i] << " ";
    // }
    // cout << endl;
    LL ans = 0;
    int cnt[2] = {0};
    cnt[psum[N] % 2]++;
    for (int i = N - 1; i >= 0; i--) {
        ans += cnt[psum[i] % 2];
        int maxx = 0;
        for (int j = i + 1; j <= N && j <= i + 70; j++) {
            maxa(maxx, in[j]);
            if (psum[j] - psum[i] < maxx * 2 && ((psum[j] + psum[i]) % 2) == 0) {
                ans--;
            }
        }
        cnt[psum[i] % 2]++;
    }
    cout << ans << endl;
    return 0;
}


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

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

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

const int MAXN = 3e5+5;

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

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

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

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


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

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

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

const int MAXN = 3e5+5;

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

int main() {
    scanf("%d", &N);
    REP(i, N) {
        LL x;
        scanf("%lld", &x);
        while (x) {
            in[i] += (x & 1);
            x >>= 1;
        }
    }
    for (int i = 1; i <= N; i++) {
        psum[i] = psum[i - 1] + in[i - 1];
    }
    int num_odd = 0;
    int num_even = 0;
    for (int i = 2; i <= N; i++) {
        if (psum[i] % 2 == 0) num_even++;
        else num_odd++;
    }
    LL ans = 0;
    for (int i = 0; i + 2 <= N; i++) {
        if (psum[i] % 2 == 0) ans += num_even;
        else ans += num_odd;
        if (psum[i + 2] % 2 == 0) num_even--;
        else num_odd--;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

#define mp make_pair
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define iterate(i, n) for (int i = 0; i < n; i++)
#define fs first
#define sc second
#define getfiles; ifstream cin("input.txt"); ofstream cout("output.txt");

const int INF = 2000000005;
const ll BIG_INF = 2000000000000000005;

using namespace std;

int main()
{
    fast;

    int n;
    cin >> n;
    vector<ll> b(n);
    for (int i = 0; i < n; i++) {
        ll col = 0;
        cin >> b[i];
        for (int j = 0; j < 64; j++)
            col += (b[i]>>j)&1;
        b[i] = col;
    }

    ll ch = 1, nch = 0, ans = 0, sum = 0;
    for (int i = n - 1; i >= 0; i--) {
        sum += b[i];
        if (sum % 2 == 1)
            ans += nch;
        else
            ans += ch;
        ll mx = 0, cursum = 0;
        for (ll r = i; r <= min(n - 1, i + 64); r++) {
            mx = max(mx, b[r]);
            cursum += b[r];
            if (cursum % 2 == 0 && mx + mx > cursum)
                ans--;
        }
        if (sum % 2 == 1)
            nch++;
        else
            ch++;
    }

    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

#define mp make_pair
#define ll long long
#define ld long double
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define iterate(i, n) for (int i = 0; i < n; i++)
#define fs first
#define sc second
#define getfiles; ifstream cin("input.txt"); ofstream cout("output.txt");

const int INF = 2000000005;
const ll BIG_INF = 2000000000000000005;

using namespace std;

int main()
{
    fast_io;

    unsigned ll ans = 0;
    unsigned ll n;
    cin >> n;
    vector<unsigned ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    unsigned ll ch = 1, nch = 0, cur = 0;

    iterate(i, n) {
        if (a[i] == 0)
            ans++;
        cur ^= a[i];
        ll col = 0;
        for (ll j = 0; j < 64; j++) {
            if ((cur >> j)&(unsigned ll)1 == 1)
                col++;
        }
        if (col % 2 == 1) {
            ans += nch;
            nch++;
        }
        else {
            if (i != 0)
                ans += ch;
            ch++;
        }
    }

    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

#define mp make_pair
#define ll long long
#define ld long double
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define iterate(i, n) for (int i = 0; i < n; i++)
#define fs first
#define sc second
#define getfiles; ifstream cin("input.txt"); ofstream cout("output.txt");

const int INF = 2000000005;
const ll BIG_INF = 2000000000000000005;

using namespace std;

int main()
{
    fast_io;

    ll ans = 0;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ll ch = 1, nch = 0, cur = 0;

    iterate(i, n) {
        cur ^= a[i];
        ll col = 0;
        for (ll j = 0; j < 64; j++) {
            if ((cur >> j)&1 == 1)
                col++;
        }
        if (col % 2 == 1) {
            ans += nch;
            nch++;
        }
        else {
            if (i != 0)
                ans += ch;
            ch++;
        }
    }

    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

#define mp make_pair
#define ll long long
#define ld long double
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define iterate(i, n) for (int i = 0; i < n; i++)
#define fs first
#define sc second
#define getfiles; ifstream cin("input.txt"); ofstream cout("output.txt");

const int INF = 2000000005;
const ll BIG_INF = 2000000000000000005;

using namespace std;

int main()
{
    fast_io;

    unsigned ll ans = 0;
    unsigned ll n;
    cin >> n;
    vector<unsigned ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    unsigned ll ch = 1, nch = 0, cur = 0;

    iterate(i, n) {
        cur ^= a[i];
        ll col = 0;
        for (ll j = 0; j < 64; j++) {
            if ((cur >> j)&(unsigned ll)1 == 1)
                col++;
        }
        if (col % 2 == 1) {
            ans += nch;
            nch++;
        }
        else {
            if (i != 0)
                ans += ch;
            ch++;
        }
    }

    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

#define mp make_pair
#define ll long long
#define ld long double
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define iterate(i, n) for (int i = 0; i < n; i++)
#define fs first
#define sc second
#define getfiles; ifstream cin("input.txt"); ofstream cout("output.txt");

const int INF = 2000000005;
const ll BIG_INF = 2000000000000000005;

using namespace std;

int main()
{
    fast_io;

    int n;
    cin >> n;
    vector<ll> b(n);
    for (int i = 0; i < n; i++) {
        int col = 0;
        cin >> b[i];
        for (int j = 0; j < 64; j++)
            col += (b[i]>>j)&1;
        b[i] = col;
    }

    ll ch = 1, nch = 0, ans = 0, sum = 0;
    for (int i = n - 1; i >= 0; i--) {
        sum += b[i];
        ans += (b[i]&1 ? nch : ch);
        ll mx = 0, cursum = 0;
        for (ll r = i; r <= min(n - 1, i + 64); r++) {
            mx = max(mx, b[r]);
            cursum += b[r];
            if (cursum % 2 == 0 && mx + mx > cursum)
                ans--;
        }
        if (sum&1)
            nch++;
        else
            ch++;
    }

    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

#define mp make_pair
#define ll long long
#define ld long double
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define iterate(i, n) for (int i = 0; i < n; i++)
#define fs first
#define sc second
#define getfiles; ifstream cin("input.txt"); ofstream cout("output.txt");

const int INF = 2000000005;
const ll BIG_INF = 2000000000000000005;

using namespace std;

int main()
{
    fast_io;

    int n;
    cin >> n;
    vector<ll> b(n);
    for (int i = 0; i < n; i++) {
        int col = 0;
        cin >> b[i];
        for (int j = 0; j < 62; j++)
            col += (b[i]>>j)&1;
        b[i] = col;
    }

    ll ch = 1, nch = 0, ans = 0, sum = 0;
    for (int i = n - 1; i >= 0; i--) {
        sum += b[i];
        ans += (b[i]&1 ? nch : ch);
        ll mx = 0, cursum = 0;
        for (ll r = i; r <= min(n - 1, i + 61); r++) {
            mx = max(mx, b[r]);
            cursum += b[r];
            if (cursum % 2 == 0 && mx + mx > cursum)
                ans--;
        }
        if (sum&1)
            nch++;
        else
            ch++;
    }

    cout << ans;

    return 0;
}


/*
Vasya has a sequence 𝑎 consisting of 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (…000000001102) into 3 (…000000000112), 12 (…0000000011002), 1026 (…100000000102) and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence.

Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with bitwise exclusive or of all elements equal to 0.

For the given sequence 𝑎1,𝑎2,…,𝑎𝑛 Vasya'd like to calculate number of integer pairs (𝑙,𝑟) such that 1≤𝑙≤𝑟≤𝑛 and sequence 𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟 is good.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    ll arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

    int onecount[n];
    memset(onecount,0,sizeof(int)*n);

    for(int i=0;i<n;i++){
    	while(arr[i]>0){
    		onecount[i]+=(arr[i]%2);
    		arr[i]/=2;
    	}
    }

    int oddcount=0;
    int evencount=0;
    ll ans=0;

    // for(int i=0;i<n;i++){
    // 	cout<<onecount[i]<<endl;
    // }

    int cumonecount[n];
    int cum=0;
    for(int i=n-1;i>=0;i--){

    	if(cum%2==0){
    		evencount++;
    	}
    	else{
    		oddcount++;
    	}

    	cum+=onecount[i];
    	cumonecount[i]=cum;

    	if(cum%2==0){
    		ans+=evencount;
    	}
    	else{
    		ans+=oddcount;
    	}
    }

    for(int i=n-1;i>=0;i--){
    	int sum=0;
    	int max=0;
    	for(int j=i;j<min(n,i+61);j++){
    		sum+=onecount[j];
    		if(onecount[j]>max)max=onecount[j];
//    			cout<<i<<" "<<j<<" "<<sum<<" "<<max<<endl;
    		if(j>i && cumonecount[i]%2 == (j<n-1?cumonecount[j]%2:0) && max>(sum-max)){
    			ans--;
    		}
    	}
    }

    cout<<ans<<endl;
}

/*
//This solution underestimates the answer

    int howmanybits[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		howmanybits[i][j]=0;
    	}
    }

    for(int i=0;i<n;i++){
    	howmanybits[i][onecount[i]]=1;
    }

    int cumulatebitcount[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		cumulatebitcount[i][j]=0;
    	}
    }

    for(int j=0;j<60;j++){
    	int cumulate=0;
    	for(int i=0;i<n;i++){
    		cumulate+=howmanybits[i][j];
    		cumulatebitcount[i][j]=cumulate%2;
    	}
    }

    ll dp[n];
    memset(dp,0,sizeof(ll)*n);

    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		dp[i]+=cumulatebitcount[i][j]*pow(2,j);
    	}
    }

    unordered_map<ll,int> myMap;

    ll ans=0;
    for(int i=0;i<n;i++){
    	ans+=myMap[dp[i]];
    	myMap[dp[i]]++;
    }

    cout<<ans<<endl;
*/

//revelation after looking at the editorial:
//    a given subsequence works if the total number of ones is even, and the largest number of ones <= sum of all others
//    condition 1 because there will be an unpaired 1 otherwise
//    condition 2 is necessary because if it is not met, then the biggest list of ones will never get covered.
//    and if it is met, then after the biggest number of ones is covered, there will be an even number of leftover ones which can cancel each other out


/*
Vasya has a sequence 𝑎 consisting of 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (…000000001102) into 3 (…000000000112), 12 (…0000000011002), 1026 (…100000000102) and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence.

Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with bitwise exclusive or of all elements equal to 0.

For the given sequence 𝑎1,𝑎2,…,𝑎𝑛 Vasya'd like to calculate number of integer pairs (𝑙,𝑟) such that 1≤𝑙≤𝑟≤𝑛 and sequence 𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟 is good.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    ll arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

    int onecount[n];
    memset(onecount,0,sizeof(int)*n);

    for(int i=0;i<n;i++){
    	while(arr[i]>0){
    		onecount[i]+=(arr[i]%2);
    		arr[i]/=2;
    	}
    }

    int oddcount=0;
    int evencount=1;
    ll ans=0;

    int cumonecount[n];
    int cum=0;
    for(int i=n-1;i>=0;i--){
    	cum+=onecount[i];
    	cumonecount[i]=cum;
    	if(cum%2==0){
    		ans+=evencount;
    		evencount++;
    	}
    	else{
    		ans+=oddcount;
    		oddcount++;
    	}
    }

    for(int i=n-1;i>=0;i--){
    	int sum=0;
    	int max=0;
    	for(int j=i;j<min(n,i+61);j++){
    		sum+=onecount[j];
    		if(onecount[j]>max)max=onecount[j];
//    		cout<<i<<" "<<j<<" "<<sum<<" "<<max<<endl;
    		if(j>i && cumonecount[i]%2 == cumonecount[j]%2 && max>(sum-max)) ans--;
    	}
    }

    cout<<ans<<endl;
}

/*
//This solution underestimates the answer

    int howmanybits[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		howmanybits[i][j]=0;
    	}
    }

    for(int i=0;i<n;i++){
    	howmanybits[i][onecount[i]]=1;
    }

    int cumulatebitcount[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		cumulatebitcount[i][j]=0;
    	}
    }

    for(int j=0;j<60;j++){
    	int cumulate=0;
    	for(int i=0;i<n;i++){
    		cumulate+=howmanybits[i][j];
    		cumulatebitcount[i][j]=cumulate%2;
    	}
    }

    ll dp[n];
    memset(dp,0,sizeof(ll)*n);

    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		dp[i]+=cumulatebitcount[i][j]*pow(2,j);
    	}
    }

    unordered_map<ll,int> myMap;

    ll ans=0;
    for(int i=0;i<n;i++){
    	ans+=myMap[dp[i]];
    	myMap[dp[i]]++;
    }

    cout<<ans<<endl;
*/

//revelation after looking at the editorial:
//    a given subsequence works if the total number of ones is even, and the largest number of ones <= sum of all others
//    condition 1 because there will be an unpaired 1 otherwise
//    condition 2 is necessary because if it is not met, then the biggest list of ones will never get covered.
//    and if it is met, then after the biggest number of ones is covered, there will be an even number of leftover ones which can cancel each other out


/*
Vasya has a sequence 𝑎 consisting of 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (…000000001102) into 3 (…000000000112), 12 (…0000000011002), 1026 (…100000000102) and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence.

Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with bitwise exclusive or of all elements equal to 0.

For the given sequence 𝑎1,𝑎2,…,𝑎𝑛 Vasya'd like to calculate number of integer pairs (𝑙,𝑟) such that 1≤𝑙≤𝑟≤𝑛 and sequence 𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟 is good.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    ll arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

    int onecount[n];
    memset(onecount,0,sizeof(int)*n);

    for(int i=0;i<n;i++){
    	while(arr[i]>0){
    		onecount[i]+=(arr[i]%2);
    		arr[i]/=2;
    	}
    }

    int oddcount=0;
    int evencount=0;
    ll ans=0;

    for(int i=0;i<n;i++){
    	cout<<onecount[i]<<endl;
    }

    int cumonecount[n];
    int cum=0;
    for(int i=n-1;i>=0;i--){

    	if(cum%2==0){
    		evencount++;
    	}
    	else{
    		oddcount++;
    	}

    	cum+=onecount[i];
    	cumonecount[i]=cum;

    	if(cum%2==0){
    		ans+=evencount;
    	}
    	else{
    		ans+=oddcount;
    	}
    }

    for(int i=n-1;i>=0;i--){
    	int sum=0;
    	int max=0;
    	for(int j=i;j<min(n,i+61);j++){
    		sum+=onecount[j];
    		if(onecount[j]>max)max=onecount[j];
    		if(j>i && cumonecount[i]%2 == (j<n-1?cumonecount[j]%2:0) && max>(sum-max)){
//    			cout<<i<<" "<<j<<" "<<sum<<" "<<max<<endl;
    			ans--;
    		}
    	}
    }

    cout<<ans<<endl;
}

/*
//This solution underestimates the answer

    int howmanybits[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		howmanybits[i][j]=0;
    	}
    }

    for(int i=0;i<n;i++){
    	howmanybits[i][onecount[i]]=1;
    }

    int cumulatebitcount[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		cumulatebitcount[i][j]=0;
    	}
    }

    for(int j=0;j<60;j++){
    	int cumulate=0;
    	for(int i=0;i<n;i++){
    		cumulate+=howmanybits[i][j];
    		cumulatebitcount[i][j]=cumulate%2;
    	}
    }

    ll dp[n];
    memset(dp,0,sizeof(ll)*n);

    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		dp[i]+=cumulatebitcount[i][j]*pow(2,j);
    	}
    }

    unordered_map<ll,int> myMap;

    ll ans=0;
    for(int i=0;i<n;i++){
    	ans+=myMap[dp[i]];
    	myMap[dp[i]]++;
    }

    cout<<ans<<endl;
*/

//revelation after looking at the editorial:
//    a given subsequence works if the total number of ones is even, and the largest number of ones <= sum of all others
//    condition 1 because there will be an unpaired 1 otherwise
//    condition 2 is necessary because if it is not met, then the biggest list of ones will never get covered.
//    and if it is met, then after the biggest number of ones is covered, there will be an even number of leftover ones which can cancel each other out


/*
Vasya has a sequence 𝑎 consisting of 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (…000000001102) into 3 (…000000000112), 12 (…0000000011002), 1026 (…100000000102) and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence.

Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with bitwise exclusive or of all elements equal to 0.

For the given sequence 𝑎1,𝑎2,…,𝑎𝑛 Vasya'd like to calculate number of integer pairs (𝑙,𝑟) such that 1≤𝑙≤𝑟≤𝑛 and sequence 𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟 is good.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    ll arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

    int onecount[n];
    memset(onecount,0,sizeof(int)*n);

    for(int i=0;i<n;i++){
    	while(arr[i]>0){
    		onecount[i]+=(arr[i]%2);
    		arr[i]/=2;
    	}
    }

    int oddcount=0;
    int evencount=0;
    ll ans=0;

    // for(int i=0;i<n;i++){
    // 	cout<<onecount[i]<<endl;
    // }

    int cumonecount[n];
    int cum=0;
    for(int i=n-1;i>=0;i--){

    	if(cum%2==0){
    		evencount++;
    	}
    	else{
    		oddcount++;
    	}

    	cum+=onecount[i];
    	cumonecount[i]=cum;

    	if(cum%2==0){
    		if(i<n-1) ans+=evencount;
    	}
    	else{
    		ans+=oddcount;
    	}
    }

    for(int i=n-1;i>=0;i--){
    	int sum=0;
    	int max=0;
    	for(int j=i;j<min(n,i+61);j++){
    		sum+=onecount[j];
    		if(onecount[j]>max)max=onecount[j];
//    			cout<<i<<" "<<j<<" "<<sum<<" "<<max<<endl;
    		if(j>i && cumonecount[i]%2 == (j<n-1?cumonecount[j]%2:0) && max>(sum-max)){
    			ans--;
    		}
    	}
    }

    cout<<ans<<endl;
}

/*
//This solution underestimates the answer

    int howmanybits[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		howmanybits[i][j]=0;
    	}
    }

    for(int i=0;i<n;i++){
    	howmanybits[i][onecount[i]]=1;
    }

    int cumulatebitcount[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		cumulatebitcount[i][j]=0;
    	}
    }

    for(int j=0;j<60;j++){
    	int cumulate=0;
    	for(int i=0;i<n;i++){
    		cumulate+=howmanybits[i][j];
    		cumulatebitcount[i][j]=cumulate%2;
    	}
    }

    ll dp[n];
    memset(dp,0,sizeof(ll)*n);

    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		dp[i]+=cumulatebitcount[i][j]*pow(2,j);
    	}
    }

    unordered_map<ll,int> myMap;

    ll ans=0;
    for(int i=0;i<n;i++){
    	ans+=myMap[dp[i]];
    	myMap[dp[i]]++;
    }

    cout<<ans<<endl;
*/

//revelation after looking at the editorial:
//    a given subsequence works if the total number of ones is even, and the largest number of ones <= sum of all others
//    condition 1 because there will be an unpaired 1 otherwise
//    condition 2 is necessary because if it is not met, then the biggest list of ones will never get covered.
//    and if it is met, then after the biggest number of ones is covered, there will be an even number of leftover ones which can cancel each other out


/*
Vasya has a sequence 𝑎 consisting of 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (…000000001102) into 3 (…000000000112), 12 (…0000000011002), 1026 (…100000000102) and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence.

Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with bitwise exclusive or of all elements equal to 0.

For the given sequence 𝑎1,𝑎2,…,𝑎𝑛 Vasya'd like to calculate number of integer pairs (𝑙,𝑟) such that 1≤𝑙≤𝑟≤𝑛 and sequence 𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟 is good.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    ll arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

    int onecount[n];
    memset(onecount,0,sizeof(int)*n);

    for(int i=0;i<n;i++){
    	while(arr[i]>0){
    		onecount[i]+=(arr[i]%2);
    		arr[i]/=2;
    	}
    }

    int oddcount=0;
    int evencount=1;
    ll ans=0;

    int cumonecount[n];
    int cum=0;
    for(int i=n-1;i>=0;i--){
    	cum+=onecount[i];
    	cumonecount[i]=cum;
    	if(cum%2==0){
    		if(i<n-1) ans+=evencount;
    		evencount++;
    	}
    	else{
    		ans+=oddcount;
    		oddcount++;
    	}
    }

    for(int i=n-1;i>=0;i--){
    	int sum=0;
    	int max=0;
    	for(int j=i;j<min(n,i+61);j++){
    		sum+=onecount[j];
    		if(onecount[j]>max)max=onecount[j];
//    		cout<<i<<" "<<j<<" "<<sum<<" "<<max<<endl;
    		if(j>i && cumonecount[i]%2 == cumonecount[j]%2 && max>(sum-max)) ans--;
    	}
    }

    cout<<ans<<endl;
}

/*
//This solution underestimates the answer

    int howmanybits[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		howmanybits[i][j]=0;
    	}
    }

    for(int i=0;i<n;i++){
    	howmanybits[i][onecount[i]]=1;
    }

    int cumulatebitcount[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		cumulatebitcount[i][j]=0;
    	}
    }

    for(int j=0;j<60;j++){
    	int cumulate=0;
    	for(int i=0;i<n;i++){
    		cumulate+=howmanybits[i][j];
    		cumulatebitcount[i][j]=cumulate%2;
    	}
    }

    ll dp[n];
    memset(dp,0,sizeof(ll)*n);

    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		dp[i]+=cumulatebitcount[i][j]*pow(2,j);
    	}
    }

    unordered_map<ll,int> myMap;

    ll ans=0;
    for(int i=0;i<n;i++){
    	ans+=myMap[dp[i]];
    	myMap[dp[i]]++;
    }

    cout<<ans<<endl;
*/

//revelation after looking at the editorial:
//    a given subsequence works if the total number of ones is even, and the largest number of ones <= sum of all others
//    condition 1 because there will be an unpaired 1 otherwise
//    condition 2 is necessary because if it is not met, then the biggest list of ones will never get covered.
//    and if it is met, then after the biggest number of ones is covered, there will be an even number of leftover ones which can cancel each other out


/*
Vasya has a sequence 𝑎 consisting of 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (…000000001102) into 3 (…000000000112), 12 (…0000000011002), 1026 (…100000000102) and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence.

Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with bitwise exclusive or of all elements equal to 0.

For the given sequence 𝑎1,𝑎2,…,𝑎𝑛 Vasya'd like to calculate number of integer pairs (𝑙,𝑟) such that 1≤𝑙≤𝑟≤𝑛 and sequence 𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟 is good.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    // if(n==1){
    // 	cout<<0<<endl;
    // 	return 0;
    // }

    ll arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

    int onecount[n];
    memset(onecount,0,sizeof(int)*n);

    for(int i=0;i<n;i++){
    	while(arr[i]>0){
    		onecount[i]+=(arr[i]%2);
    		arr[i]/=2;
    	}
    }

    int oddcount=0;
    int evencount=0;
    ll ans=0;

    // for(int i=0;i<n;i++){
    // 	cout<<onecount[i]<<endl;
    // }

    int cumonecount[n+1];
    cumonecount[n]=0;
    int cum=0;
    for(int i=n-1;i>=0;i--){
    	cum+=onecount[i];
    	cumonecount[i]=cum;
    }

    for(int i=n-2;i>=0;i--){
    	if(cumonecount[i+2]%2==0){
    		evencount++;
    	}
    	else{
    		oddcount++;
    	}

    	if(cumonecount[i]%2==0){
    		ans+=evencount;
    	}
    	else{
    		ans+=oddcount;
    	}
    }

    for(int i=n-1;i>=0;i--){
    	int sum=0;
    	int max=0;
    	for(int j=i;j<min(n,i+62);j++){
    		sum+=onecount[j];
    		if(onecount[j]>max)max=onecount[j];
    		if(j>i && max>(sum-max)){
    			if((cumonecount[i]-cumonecount[j+1])%2 == 0){
//    				cout<<i<<" "<<j<<endl;
	    			ans--;
	    		}
    		}
    	}
    }

    cout<<ans<<endl;
}

/*
//This solution underestimates the answer

    int howmanybits[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		howmanybits[i][j]=0;
    	}
    }

    for(int i=0;i<n;i++){
    	howmanybits[i][onecount[i]]=1;
    }

    int cumulatebitcount[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		cumulatebitcount[i][j]=0;
    	}
    }

    for(int j=0;j<60;j++){
    	int cumulate=0;
    	for(int i=0;i<n;i++){
    		cumulate+=howmanybits[i][j];
    		cumulatebitcount[i][j]=cumulate%2;
    	}
    }

    ll dp[n];
    memset(dp,0,sizeof(ll)*n);

    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		dp[i]+=cumulatebitcount[i][j]*pow(2,j);
    	}
    }

    unordered_map<ll,int> myMap;

    ll ans=0;
    for(int i=0;i<n;i++){
    	ans+=myMap[dp[i]];
    	myMap[dp[i]]++;
    }

    cout<<ans<<endl;
*/

//revelation after looking at the editorial:
//    a given subsequence works if the total number of ones is even, and the largest number of ones <= sum of all others
//    condition 1 because there will be an unpaired 1 otherwise
//    condition 2 is necessary because if it is not met, then the biggest list of ones will never get covered.
//    and if it is met, then after the biggest number of ones is covered, there will be an even number of leftover ones which can cancel each other out


/*
Vasya has a sequence 𝑎 consisting of 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (…000000001102) into 3 (…000000000112), 12 (…0000000011002), 1026 (…100000000102) and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence.

Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with bitwise exclusive or of all elements equal to 0.

For the given sequence 𝑎1,𝑎2,…,𝑎𝑛 Vasya'd like to calculate number of integer pairs (𝑙,𝑟) such that 1≤𝑙≤𝑟≤𝑛 and sequence 𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟 is good.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    ll arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

//This solution underestimates the answer
    int onecount[n];
    memset(onecount,0,sizeof(int)*n);

    for(int i=0;i<n;i++){
    	while(arr[i]>0){
    		onecount[i]+=(arr[i]%2);
    		arr[i]/=2;
    	}
    }

    int howmanybits[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		howmanybits[i][j]=0;
    	}
    }

    for(int i=0;i<n;i++){
    	howmanybits[i][onecount[i]]=1;
    }

    int cumulatebitcount[n][60];
    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		cumulatebitcount[i][j]=0;
    	}
    }

    for(int j=0;j<60;j++){
    	int cumulate=0;
    	for(int i=0;i<n;i++){
    		cumulate+=howmanybits[i][j];
    		cumulatebitcount[i][j]=cumulate%2;
    	}
    }

    ll dp[n];
    memset(dp,0,sizeof(ll)*n);

    for(int i=0;i<n;i++){
    	for(int j=0;j<60;j++){
    		dp[i]+=cumulatebitcount[i][j]*pow(2,j);
    	}
    }

    unordered_map<ll,int> myMap;

    ll ans=0;
    for(int i=0;i<n;i++){
    	ans+=myMap[dp[i]];
    	myMap[dp[i]]++;
    }

    cout<<ans*2<<endl;

}


                                                                   //author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    int A[n],b[n];
    int po[61];
    po[0]=1;
    for(int i=1;i<=60;i++)
    po[i] - po[i-1]*2;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        //test1(A[i]);
        int x = __builtin_popcount(A[i]);
       // test1(x);
        b[i]=x;
    }
    int pref[n][2]={{0}};
    int suff[n+1]={0};
    int ans=0;
    for(int i=n-1;i>=0;i--)
    {
        suff[i] = suff[i+1] + b[i];
        int cur=0,mx=0;
        for(int j=i;j<min(n,i+62);j++)
        {
            cur += b[j];
            mx=max(mx,b[j]);

            //test4(i,j,cur,mx);
            if(cur>=mx+mx&&cur%2==0)
            ans++;
        }
        if(i+62<n)
        {
            ans += pref[i+62][suff[i]%2];
        }
        for(int j=0;j<2;j++)
        pref[i][j] = pref[i+1][j];

        pref[i][suff[i]%2]++;
    }
    cout<<ans;
return 0;
}


                                                                   //author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    int A[n],b[n];
    int po[61];
    po[0]=1;
    for(int i=1;i<=60;i++)
    po[i] - po[i-1]*2;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        //test1(A[i]);
        int x = __builtin_popcountll(A[i]);
       // test1(x);
        b[i]=x;
    }
    int pref[n+1][2];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<2;j++)
        pref[i][j]=0;
    }
    int suff[n+1]={0};
    int ans=0;
    for(int i=n-1;i>=0;i--)
    {
        suff[i] = suff[i+1] + b[i];
        int cur=0,mx=0;
        for(int j=i;j<min(n,i+62);j++)
        {
            cur += b[j];
            mx=max(mx,b[j]);

            //test4(i,j,cur,mx);
            if(cur>=mx+mx&&cur%2==0)
            ans++;
        }
        if(i+62<n)
        {
            ans += pref[i+62][suff[i]%2];
        }
        for(int j=0;j<2;j++)
        pref[i][j] = pref[i+1][j];

        pref[i][suff[i]%2]++;
    }
    cout<<ans;
return 0;
}


                                                                   //author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    int A[n],b[n];
    int po[61];
    po[0]=1;
    for(int i=1;i<=60;i++)
    po[i] - po[i-1]*2;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        //test1(A[i]);
        int x = __builtin_popcountll(A[i]);
       // test1(x);
        b[i]=x;
    }
    int pref[n][2]={{0}};
    int suff[n+1]={0};
    int ans=0;
    for(int i=n-1;i>=0;i--)
    {
        suff[i] = suff[i+1] + b[i];
        int cur=0,mx=0;
        for(int j=i;j<min(n,i+62);j++)
        {
            cur += b[j];
            mx=max(mx,b[j]);

            //test4(i,j,cur,mx);
            if(cur>=mx+mx&&cur%2==0)
            ans++;
        }
        if(i+62<n)
        {
            ans += pref[i+62][suff[i]%2];
        }
        for(int j=0;j<2;j++)
        pref[i][j] = pref[i+1][j];

        pref[i][suff[i]%2]++;
    }
    cout<<ans;
return 0;
}


                                                                   //author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    int A[n],b[n];
    int po[61];
    po[0]=1;
    for(int i=1;i<=60;i++)
    po[i] - po[i-1]*2;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        //test1(A[i]);
        int x = __builtin_popcountll(A[i]);
       // test1(x);
        b[i]=x;
    }
    int pref[n+1][2];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<2;j++)
        pref[i][j]=0;
    }
    int suff[n+1]={0};
    int ans=0;
    pref[n][0]=1;
    for(int i=n-1;i>=0;i--)
    {
        suff[i] = suff[i+1] + b[i];
        int cur=0,mx=0;
        for(int j=i;j<min(n,i+65);j++)
        {
            cur += b[j];
            mx=max(mx,b[j]);

            //test4(i,j,cur,mx);
            if(cur<mx+mx&&cur%2==0)
            ans--;
        }

        ans += pref[i+1][suff[i]%2];
        for(int j=0;j<2;j++)
        pref[i][j] = pref[i+1][j];

        pref[i][suff[i]%2]++;
    }
    cout<<ans;
return 0;
}


                                                                   //author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    int A[n],b[n];
    int po[61];
    po[0]=1;
    for(int i=1;i<=60;i++)
    po[i] - po[i-1]*2;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        //test1(A[i]);
        int x = __builtin_popcountll(A[i]);
       // test1(x);
        b[i]=x;
    }
    int pref[n+1][2];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<2;j++)
        pref[i][j]=0;
    }
    int suff[n+1]={0};
    int ans=0;
    for(int i=n-1;i>=0;i--)
    {
        suff[i] = suff[i+1] + b[i];
        int cur=0,mx=0;
        for(int j=i;j<min(n,i+65);j++)
        {
            cur += b[j];
            mx=max(mx,b[j]);

            //test4(i,j,cur,mx);
            if(cur>=mx+mx&&cur%2==0)
            ans++;
        }
        if(i+65<n)
        {
            ans += pref[i+65][suff[i]%2];
        }
        for(int j=0;j<2;j++)
        pref[i][j] = pref[i+1][j];

        pref[i][suff[i]%2]++;
    }
    cout<<ans;
return 0;
}


                                                                   //author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);
	int n;
    cin>>n;
    int A[n],b[n];
    int po[61];
    po[0]=1;
    for(int i=1;i<=60;i++)
    po[i] - po[i-1]*2;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        //test1(A[i]);
        int x = __builtin_popcountll(A[i]);
       // test1(x);
        b[i]=x;
    }
    int pref[n+1][2];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<2;j++)
        pref[i][j]=0;
    }
    int suff[n+1]={0};
    int ans=0;
    for(int i=n-1;i>=0;i--)
    {
        suff[i] = suff[i+1] + b[i];
        int cur=0,mx=0;
        for(int j=i;j<min(n,i+65);j++)
        {
            cur += b[j];
            mx=max(mx,b[j]);

            //test4(i,j,cur,mx);
            if(cur>=mx+mx&&cur%2==0)
            ans++;
        }
        if(i+65<n)
        {
            ans += pref[i+62][suff[i]%2];
        }
        for(int j=0;j<2;j++)
        pref[i][j] = pref[i+1][j];

        pref[i][suff[i]%2]++;
    }
    cout<<ans;
return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
using usi = unsigned short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()

//debug defines
#ifdef HOME
    #define OL cout << "Oliva" << endl;
    #define PO cout << "Pomelo" << endl;
    #define debug(x) cout << #x << " " << x << endl;
    #define debug_v(x) cout << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
    #define debug_dd(x) print(x) cout << endl;
#else
    #define OL 0
    #define PO 0
    #define debug(x) 0
    #define debug_v(x) 0
    #define debug_dd(x) 0
#endif // HOME

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int C = 70;
    int n;
    cin >> n;
    ll in;
    ll ans = 0;
    vector<pair<pll, pll>> pref(n + 1);
    pref[0] = {{0, 0}, {0, 0}};
    vector<ll> max_cnt(n + 1);
    max_cnt[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> in;
        int t = 0;
        while (in)
        {
            t += in % 2;
            in >>= 1;
        }
        debug(t);
        max_cnt[i + 1] = t;
        pref[i + 1] = pref[i];
        pref[i + 1].ff.ss += t;
        pref[i + 1].ff.ff = t;
        if (pref[i + 1].ff.ss % 2 == 0)
            pref[i + 1].ss.ff++;
        else
            pref[i + 1].ss.ss++;
        debug(i);
        if (i <= C)
        {
            for (int j = i; j > 0; --j)
            {
                max_cnt[j] = max(max_cnt[j], max_cnt[j + 1]);
                if (pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff >= 2 * max_cnt[j])
                {
                    if ((pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff) % 2 == 0)
                        ++ans;
                }
            }
        }
        else
        {
            PO;
            for (int j = i; j > i - C; --j)
            {
                debug(j);
                max_cnt[j] = max(max_cnt[j], max_cnt[j + 1]);
                if (pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff >= 2 * max_cnt[j])
                {
                    if ((pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff) % 2 == 0)
                        ++ans;
                }
                debug(ans);
            }
            ans += (pref[i + 1].ff.ss % 2 == 1 ? pref[i - C].ss.ff : pref[i - C].ss.ss);
        }
        debug(i);
        debug(ans);
        OL;
        //cout << pref[i + 1].ff.ff << " " << pref[i + 1].ff.ss << " " << pref[i + 1].ss.ff << " " << pref[i + 1].ss.ss << endl;
    }
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
using usi = unsigned short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()

//debug defines
#ifdef HOME
    #define OL cout << "Oliva" << endl;
    #define PO cout << "Pomelo" << endl;
    #define debug(x) cout << #x << " " << x << endl;
    #define debug_v(x) cout << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
    #define debug_dd(x) print(x) cout << endl;
#else
    #define OL 0
    #define PO 0
    #define debug(x) 0
    #define debug_v(x) 0
    #define debug_dd(x) 0
#endif // HOME

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int C = 70;
    int n;
    cin >> n;
    ll in;
    ll ans = 0;
    vector<pair<pll, pll>> pref(n + 1);
    pref[0] = {{0, 0}, {1, 0}};
    vector<ll> max_cnt(n + 1);
    max_cnt[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> in;
        int t = 0;
        while (in)
        {
            t += in % 2;
            in >>= 1;
        }
        debug(t);
        max_cnt[i + 1] = t;
        pref[i + 1] = pref[i];
        pref[i + 1].ff.ss += t;
        pref[i + 1].ff.ff = t;
        if (pref[i + 1].ff.ss % 2 == 0)
            pref[i + 1].ss.ff++;
        else
            pref[i + 1].ss.ss++;
        debug(i);
        if (i <= C)
        {
            for (int j = i; j > 0; --j)
            {
                max_cnt[j] = max(max_cnt[j], max_cnt[j + 1]);
                if (pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff >= 2 * max_cnt[j])
                {
                    if ((pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff) % 2 == 0)
                        ++ans;
                }
            }
        }
        else
        {
            PO;
            for (int j = i; j > i - C; --j)
            {
                debug(j);
                max_cnt[j] = max(max_cnt[j], max_cnt[j + 1]);
                if (pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff >= 2 * max_cnt[j])
                {
                    if ((pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff) % 2 == 0)
                        ++ans;
                }
                debug(ans);
            }
            ans += (pref[i + 1].ff.ss % 2 == 1 ? pref[i - C - 1].ss.ss : pref[i - C].ss.ff);
        }
        debug(i);
        debug(ans);
        OL;
        //cout << pref[i + 1].ff.ff << " " << pref[i + 1].ff.ss << " " << pref[i + 1].ss.ff << " " << pref[i + 1].ss.ss << endl;
    }
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
using usi = unsigned short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()

//debug defines
#ifdef HOME
    #define OL cout << "Oliva" << endl;
    #define PO cout << "Pomelo" << endl;
    #define debug(x) cout << #x << " " << x << endl;
    #define debug_v(x) cout << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
    #define debug_dd(x) print(x) cout << endl;
#else
    #define OL 0
    #define PO 0
    #define debug(x) 0
    #define debug_v(x) 0
    #define debug_dd(x) 0
#endif // HOME

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    ll in;
    ll ans = 0;
    vector<pair<pll, pll>> pref(n + 1);
    pref[0] = {{0, 0}, {0, 0}};
    vector<ll> max_cnt(n + 1);
    max_cnt[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> in;
        int t = 0;
        while (in)
        {
            t += in % 2;
            in >>= 1;
        }
        debug(t);
        max_cnt[i + 1] = t;
        pref[i + 1] = pref[i];
        pref[i + 1].ff.ss += t;
        pref[i + 1].ff.ff = t;
        if (pref[i + 1].ff.ss % 2 == 0)
            pref[i + 1].ss.ff++;
        else
            pref[i + 1].ss.ss++;
        if (i <= 5000)
        {
            for (int j = i; j > 0; --j)
            {
                max_cnt[j] = max(max_cnt[j], max_cnt[j + 1]);
                if (pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff >= 2 * max_cnt[j])
                {
                    if ((pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff) % 2 == 0)
                        ++ans;
                }
            }
        }
        else
        {
            for (int j = i; j >= i - 70; --j)
            {
                max_cnt[j] = max(max_cnt[j], max_cnt[j + 1]);
                if (pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff >= 2 * max_cnt[j])
                {
                    if ((pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff) % 2 == 0)
                        ++ans;
                }
            }
            ans += (pref[i + 1].ff.ss % 2 == 1 ? pref[i - 71].ss.ss : pref[i - 71].ss.ff);
        }
        debug(ans);
    }
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
using usi = unsigned short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()

//debug defines
#ifdef HOME
    #define OL cout << "Oliva" << endl;
    #define PO cout << "Pomelo" << endl;
    #define debug(x) cout << #x << " " << x << endl;
    #define debug_v(x) cout << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
    #define debug_dd(x) print(x) cout << endl;
#else
    #define OL 0
    #define PO 0
    #define debug(x) 0
    #define debug_v(x) 0
    #define debug_dd(x) 0
#endif // HOME

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    ll in;
    ll cnt[2] = {0, 0};
    ll ans = 0;
    vector<pair<pll, pll>> pref(n + 1);
    pref[0] = {{0, 0}, {1, 0}};
    vector<ll> max_cnt(n + 1);
    max_cnt[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> in;
        int t = 0;
        while (in)
        {
            t += in % 2;
            in >>= 1;
        }
        debug(t);
        max_cnt[i + 1] = t;
        pref[i + 1] = pref[i];
        pref[i + 1].ff.ss += t;
        pref[i + 1].ff.ff = t;
        if (pref[i + 1].ff.ss % 2 == 0)
            pref[i + 1].ss.ff++;
        else
            pref[i + 1].ss.ss++;
        for (int j = i; j >= max(0, i - 65); --j)
        {
            max_cnt[j] = max(max_cnt[j], max_cnt[j + 1]);
            if (pref[i].ff.ss - pref[j].ff.ss + pref[j].ss.ss >= max_cnt[j])
            {
                ans += (pref[i + 1].ff.ss % 2 ? pref[j].ss.ss : pref[j].ss.ff);
                break;
            }
        }
    }
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
using usi = unsigned short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()

//debug defines
#ifdef HOME
    #define OL cout << "Oliva" << endl;
    #define PO cout << "Pomelo" << endl;
    #define debug(x) cout << #x << " " << x << endl;
    #define debug_v(x) cout << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
    #define debug_dd(x) print(x) cout << endl;
#else
    #define OL 0
    #define PO 0
    #define debug(x) 0
    #define debug_v(x) 0
    #define debug_dd(x) 0
#endif // HOME

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    ll in;
    ll cnt[2] = {0, 0};
    ll ans = 0;
    vector<pair<pll, pll>> pref(n + 1);
    pref[0] = {{0, 0}, {0, 0}};
    vector<ll> max_cnt(n + 1);
    max_cnt[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> in;
        int t = 0;
        while (in)
        {
            t += in % 2;
            in >>= 1;
        }
        debug(t);
        max_cnt[i + 1] = t;
        pref[i + 1] = pref[i];
        pref[i + 1].ff.ss += t;
        pref[i + 1].ff.ff = t;
        if (pref[i + 1].ff.ss % 2 == 0)
            pref[i + 1].ss.ff++;
        else
            pref[i + 1].ss.ss++;
        if (i <= 65)
        {
            for (int j = i; j > 0; --j)
            {
                max_cnt[j] = max(max_cnt[j], max_cnt[j + 1]);
                if (pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff >= 2 * max_cnt[j])
                {
                    if ((pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff) % 2 == 0)
                        ++ans;
                }
            }
        }
        else
        {
            for (int j = i; j >= i - 65; --j)
            {
                max_cnt[j] = max(max_cnt[j], max_cnt[j + 1]);
                if (pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff >= 2 * max_cnt[j])
                {
                    if ((pref[i + 1].ff.ss - pref[j].ff.ss + pref[j].ff.ff) % 2 == 0)
                        ++ans;
                }
            }
            ans += (pref[i + 1].ff.ss % 2 == 1 ? pref[i - 66].ss.ss : pref[i - 66].ss.ff);
        }
        debug(ans);
    }
    cout << ans;

    return 0;
}


////#include <bits/stdc++.h>
////#include <ext/pb_ds/assoc_container.hpp>
////#include <ext/pb_ds/tree_policy.hpp>
////
////#define pii              pair <int,int>
////#define pll              pair <long long,long long>
////#define sc               scanf
////#define pf               printf
////#define Pi               2*acos(0.0)
////#define ms(a,b)          memset(a, b, sizeof(a))
////#define pb(a)            push_back(a)
////#define MP               make_pair
////#define db               double
////#define ll               long long
////#define EPS              10E-10
////#define ff               first
////#define ss               second
////#define sqr(x)           (x)*(x)
////#define D(x)             cerr<<#x " = "<<(x)<<endl
////#define VI               vector <int>
////#define DBG              pf("Hi\n")
////#define MOD              1000000007
////#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
////#define SZ(a)            (int)a.size()
////#define sf(a)            scanf("%d",&a)
////#define sfl(a)           scanf("%lld",&a)
////#define sff(a,b)         scanf("%d %d",&a,&b)
////#define sffl(a,b)        scanf("%lld %lld",&a,&b)
////#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
////#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
////#define stlloop(v)       for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
////#define loop(i,n)        for(int i=0;i<n;i++)
////#define loop1(i,n)       for(int i=1;i<=n;i++)
////#define REP(i,a,b)       for(int i=a;i<b;i++)
////#define RREP(i,a,b)      for(int i=a;i>=b;i--)
////#define TEST_CASE(t)     for(int z=1;z<=t;z++)
////#define PRINT_CASE       printf("Case %d: ",z)
////#define LINE_PRINT_CASE  printf("Case %d:\n",z)
////#define CASE_PRINT       cout<<"Case "<<z<<": "
////#define all(a)           a.begin(),a.end()
////#define intlim           2147483648
////#define infinity         (1<<28)
////#define ull              unsigned long long
////#define gcd(a, b)        __gcd(a, b)
////#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
////
////using namespace std;
////
//////using namespace __gnu_pbds;
//////typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
////
////
/////*----------------------Graph Moves----------------*/
//////const int fx[]={+1,-1,+0,+0};
//////const int fy[]={+0,+0,+1,-1};
//////const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//////const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//////const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//////const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/////*------------------------------------------------*/
////
/////*-----------------------Bitmask------------------*/
//////int Set(int N,int pos){return N=N | (1<<pos);}
//////int reset(int N,int pos){return N= N & ~(1<<pos);}
//////bool check(int N,int pos){return (bool)(N & (1<<pos));}
/////*------------------------------------------------*/
////
////#define mx 100005
////
////int phi[mx];
//////string str[mx];
////vector< pair<int, string> >g[mx];
////char ss[300005];
////int len;
////
////void prefix_func()
////{
////    len=strlen(ss);
////    int k=0;
////    phi[0]=0;
////    for(int i=1;i<len;i++)
////    {
////        while(k>0 && ss[i]!=ss[k]) k=phi[k-1];
////        if(ss[k]==ss[i]) k++;
////            phi[i]=k;
////    }
//////    for(int i=0;i<len;i++)
//////        cout<<phi[i]<<" ";
////}
////
////int ans=0;
////
////
////void dfs(int u, int kk)
////{
////    for(int j=0;j<SZ(g[u]);j++)
////    {
////        int v=g[u][j].ff;
////        int k=kk;
//////        string dd=str[v];
////        for(int i=0;i<SZ(g[u][j].ss);i++)
////        {
////            while(k>0 && g[u][j].ss[i]!=ss[k]) k=phi[k-1];
////            if(ss[k]==g[u][j].ss[i]) k++;
////            if(k==len)
////            {
////                ans++;
//////                k=phi[k-1];
////            }
////        }
////        dfs(v,k);
////    }
////}
////
////int main()
////{
//////    freopen("in.txt","r",stdin);
//////	  freopen("out.txt","w",stdout);
////    int n;
////    sf(n);
////    for(int i=2;i<=n;i++)
////    {
////        int a;
////        scanf("%d %s",&a, ss);
////        g[a].pb(MP(i,ss));
//////        str[i]=ss;
////    }
////
////    scanf("%s",ss);
////
////    prefix_func();
////    dfs(1,0);
////    printf("%d\n",ans);
////
////    return 0;
////}
//
//
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<deque>
#include<climits>
#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define Max(a,b)    (a>b?a:b)
#define Min(a,b)    (a<b?a:b)
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair

#define NL         printf("\n");

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define Case(a)    printf("Case %d:",a)
#define caseh(a)   printf("Case #%d: ",a)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define PR(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++) {  cout << *it << " "; } cout << endl;

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

int toInt(string s)  { int sm; stringstream ss(s); ss>>sm; return sm; }
int toLlint(string s) { long long int sm; stringstream ss(s); ss>>sm; return sm;}
int cdigittoint(char ch){return ch-'0';}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
bool isConst(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  300007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

#define base ((1<<l)-1)
#define lft (idx<<1)
#define rgt (lft|1)
#define mid ((l+r)>>1)

struct Edge{
    int v;
    string s;

    Edge(int _v,string _s){
        v = _v;
        s = _s;
    }
};

char s[MX];
int  f[MX],l;
vector<Edge> adj[MX];

void Prefix(int n){
    int i=0,j=-1;
    f[0] = -1;

    while (i<n){
        while (j != -1 && s[j] != s[i])     j = f[j];

        i++;j++;
        f[i] = j;
    }
}

LL Dfs(int u,int pos){
    LL ans = 0;

    for(auto v:adj[u]){
        int i=0,j=pos,n=v.s.length(),m=l;

        while (i<n){
            while (j != -1 && v.s[i] != s[j])   j = f[j];

            i++;j++;

            if (j == m)     ans ++,j = f[j];
        }

        ans += Dfs( v.v,j );
    }

    return ans;
}

int main()
{
    DI(n);

    for (int i=2;i<=n;i++){
        DI(x);  S("%s",s);

        adj[x].PB( Edge(i,s) );
    }

    S("%s",s);      l = strlen(s);
    Prefix(l);

    cout << Dfs(1,0) << endl;

return 0;
}