- Sorry, it was a typo. We didn't mean to hurt your feelings like that.
- More often than not, we are stuck rationalizing whatever disreputable deeds we engage in for the sake of moving on. But, it is important in this process that we do not stray away from the one truth we have, which is the present moment.
In the quest of simplifying historical data for the sake of potential clarity, we can find ourselves destroying relationships and communities. What could be holier than the present, we ask of you? What is the point when mere abstention becomes problematic revisionism, and why shouldn't we believe you have crossed this threshold already?
- The Author with the Very Hungarian Catterpilar
Task
Consider the bitwise operation (hereby noted as ). The bitwise operation (denoted by ) is a binary operation that compares each bit of two operands and returns a new value where each bit is set to only if the corresponding bits of both operands are . In other words, it performs a logical AND on every pair of corresponding bits. For example, given two 4-bit binary numbers and , their bitwise AND is . This operation is defined in as , which works similarly to any other operator (e.g. etc.).
We call a sequence of numbers if there exists an index with such that .
Given a sequence of natural numbers , determine how many pairs of indexes bound a subarray. That is, count the number of pairs of numbers with with such that is a sequence.
Input data
The first line contains a natural number .
The second line contains  natural numbers, representing the elements of the sequence .
Output data
Print a single number: the sought number of pairs of indexes that satisfy the property described in the statement.
Restrictions
- .
- .
| # | Points | Restrictions | 
|---|---|---|
| 1 | 10 | , | 
| 2 | 3 | , all values are equal | 
| 3 | 13 | , | 
| 4 | 11 | , | 
| 5 | 6 | , | 
| 6 | 11 | , | 
| 7 | 14 | , , for | 
| 8 | 13 | |
| 9 | 19 | No additional restrictions | 
Example
stdin
5
1 1 4 0 2
stdout
13
Explanation
For the given example, the intervals that satisfy the property are: , , , , , , , , , , , , .