#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000007
#define INF 1000000000000000LL
#define MOD 1000000007
#define sd(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define PB push_back
#define F first
#define S second
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define dd double
#define PI 3.14159265358979323846
ll n;
ll A[MAX];
ll B[MAX];
ll x;
int main(int argc, char const *argv[])
{
// freopen("input.txt", "r" , stdin);
// freopen("output.txt", "w", stdout);
memset( A, 0, sizeof A);
memset(B, 0, sizeof B);
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin>>n;
rep(i,1,n+1)
{
cin>>x;
int y = __builtin_popcount(x);
A[i] = y;
B[i] = y;
}
if(n == 1)
{
cout<<0<<endl;
return 0;
}
rep(i,2,n+1)
A[i] += A[i-1];
ll res = 0;
ll odd = 0, even = 0;
rep(i,1,n+1)
{
if(A[i]&1)
{
++odd;
if(odd > 1)
{
res += odd;
ll maxm;
for(int j = i; j > (i-66, 0); --j)
{
maxm = max(maxm, B[j]);
if(A[j-1]%2 == 1 and (maxm > (A[i]- A[j-1])/2))
--res;
}
}
}
else
{
++even;
if(even > 1)
{
res += even;
ll maxm;
for(int j = i; j > (i-66, 0); --j)
{
maxm = max(maxm, B[j]);
if(A[j-1]%2 == 0 and (maxm > (A[i]- A[j-1])/2))
--res;
}
}
}
}
cout<<res<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIE1BWCAxMDAwMDA3CiNkZWZpbmUgSU5GIDEwMDAwMDAwMDAwMDAwMDBMTAojZGVmaW5lIE1PRCAxMDAwMDAwMDA3CiNkZWZpbmUgc2QoeCkgc2NhbmYoIiVkIiwmeCkKI2RlZmluZSBzbGwoeCkgc2NhbmYoIiVsbGQiLCZ4KQojZGVmaW5lIFBCIHB1c2hfYmFjawojZG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