#P1609F. Interesting Sections
Interesting Sections
No submission language available for this problem.
Description

William has an array of non-negative numbers . He wants you to find out how many segments pass the check. The check is performed in the following manner:
- The minimum and maximum numbers are found on the segment of the array starting at and ending at .
- The check is considered to be passed if the binary representation of the minimum and maximum numbers have the same number of bits equal to 1.
The first line contains a single integer (), the size of array .
The second line contains integers (), the contents of array .
Output a single number — the total number of segments that passed the check.
Input
The first line contains a single integer (), the size of array .
The second line contains integers (), the contents of array .
Output
Output a single number — the total number of segments that passed the check.