from bisect import bisect_left
n=int(input())
b=list(map(int,input().split()))
res=[]
for j in range(n):
    res.append(bin(b[j]).count('1'))

s=[[] for i in range(61)]
s1=[]
s11=[]
s2=[0]
s22=[0]
su=0
ans=0
for i in range(1,n+1):
    s[res[i-1]].append(i)
    if (su+res[i-1])%2:
        for j in range(res[i-1],61):
            if s[j]!=[]:
                ind=s[j][-1]
                val=su+res[i-1]-2*j
                ind1=bisect_left(s1,val+1)-1
                if ind1>=0:
                    if s11[ind1]<ind:
                        ans+=(ind1)+1
                    else:
                        ind2=bisect_left(s11,ind)
                        ans+=ind2

        s1.append(su+res[i-1])
        s11.append(i)

    else:
        for j in range(res[i-1], 61):
            if s[j] != []:
                ind = s[j][-1]
                val = su + res[i-1] - 2 * j
                ind1 = bisect_left(s2, val + 1) - 1
                if ind1>=0:
                    if s22[ind1] < ind:
                        ans += (ind1) + 1
                    else:
                        ind2 = bisect_left(s22, ind)
                        ans += ind2

        s2.append(su + res[i-1])
        s22.append(i)

    su+=res[i-1]


print(ans)






