#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 ordered_set                                                            \
  tree<int, null_type, less<int>, rb_tree_tag,                                 \
       tree_order_statistics_node_update>
#define ll long long int
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll, ll>
const ll mod = 998244353;
const ll M = 2e5 + 5;
ll a[M],s[M],o[M],e[M];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]=__builtin_popcount(a[i]);
    }
    for(i=1;i<=n;i++)
    {
        s[i]=a[i]+s[i-1];
    }
    for(i=n;i>=1;i--)
    {
        if(s[i]%2)
            o[i]++;
        else
            e[i]++;
        o[i]+=o[i+1];
        e[i]+=e[i+1];
    }
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        if(s[i-1]%2)
        {
            ans+=o[i];
            ll mx=0;
            for(ll j=i;j<=min(i+80,n);j++)
            {
                mx=max(mx,a[j]);
                if(s[j]%2 && s[j]-s[i-1]<2*mx)
                {
                    ans--;
                }
            }
        }
        else
        {
            ans+=e[i];
            ll mx=0;
            for(ll j=i;j<=min(n,i+80);j++)
            {
                mx=max(mx,a[j]);
                if(s[j]%2==0 && s[j]-s[i-1]<2*mx)
                {
                    ans--;
                }
            }
        }
    }
    cout<<ans<<"\n";
}