Consider a sequence of non-negative integers from $$$L$$$ to $$$R$$$ inclusive. Split this sequence into $$$n$$$ non-empty segments and calculate the bitwise "OR" of all numbers in each segment. Denote the result for the $$$i$$$-th segment as $$$f_i$$$.
You need to solve the inverse problem: given $$$f_1, f_2, \ldots, f_n$$$, find the number of ways first to select $$$L$$$ and $$$R$$$, and then split all numbers from $$$L$$$ to $$$R$$$ into $$$n$$$ non-empty segments, such that the results of calculating the bitwise "OR" in each segment are equal to $$$f_1, f_2, \ldots, f_n$$$ respectively.
The bitwise "OR" of two non-negative integers is calculated as follows: Write down both arguments in binary, then the $$$i$$$-th bit of the result equals $$$1$$$ iff at least one argument has $$$1$$$ at that place. For example, $$$(17 \mathbin{|} 13) = (10001_2 \mathbin{|} 01101_2) = 11101_2 = 29$$$.
The first line contains integer $$$n$$$ ($$$1 \le n \le 200\,000$$$). The second line contains $$$n$$$ integers $$$f_i$$$ ($$$0 \le f_i \lt 2^{60}$$$).
Output a single integer — the number of ways to choose a sequence of consecutive integers and then split it into $$$n$$$ segments. Because the answer can be huge, print it modulo $$$1\,000\,000\,007$$$.
| Subtask | Points | Constraints | |
| 1 | 16 | $$$n = 1$$$ | |
| 2 | 12 | $$$n \le 16$$$, $$$0 \le f_i | lt; 16$$$ |
| 3 | 13 | $$$n \le 256$$$, $$$0 \le f_i | lt; 256$$$ |
| 4 | 18 | $$$n \le 1024$$$, $$$0 \le f_i | lt; 1024$$$ |
| 5 | 24 | $$$n \le 30\,000$$$, $$$0 \le f_i | lt; 2^{30}$$$ |
| 6 | 17 | No additional constraints |
3 0 7 7
4
1 11
6
2 4 6
0
In the first example, there are four ways to split a sequence of consecutive integers into three parts such that their bitwise "OR"s are $$$0$$$, $$$7$$$ and $$$7$$$:
| Name |
|---|


