← Home
write a go solution for Description:
Vasya has a sequence a consisting of n integers a_1,a_2,...,a_n. 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 (...00000000110_2) into 3 (...00000000011_2), 12 (...000000001100_2), 1026 (...10000000010_2) 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 a_1,a_2,ldots,a_n Vasya'd like to calculate number of integer pairs (l,r) such that 1<=l<=r<=n and sequence a_l,a_l+1,...,a_r is good.

Input Format:
The first line contains a single integer n (1<=n<=3*10^5) — length of the sequence.

The second line contains n integers a_1,a_2,...,a_n (1<=a_i<=10^18) — the sequence a.

Output Format:
Print one integer — the number of pairs (l,r) such that 1<=l<=r<=n and the sequence a_l,a_l+1,...,a_r is good.

Note:
In the first example pairs (2,3) and (1,3) are valid. Pair (2,3) is valid since a_2=7arrow11, a_3=14arrow11 and 11oplus11=0, where oplus — bitwise exclusive or. Pair (1,3) is valid since a_1=6arrow3, a_2=7arrow13, a_3=14arrow14 and 3oplus13oplus14=0.

In the second example pairs (1,2), (2,3), (3,4) and (1,4) are valid.. Output only the code with no comments, explanation, or additional text.