P8569 [JRKSJ R6] The Seventh School District

Background

![](https://cdn.luogu.com.cn/upload/image_hosting/jswrnw5w.png) This problem was originally meant to be solved on a Tree Diagram, but the Tree Diagram was blasted by some organization’s cosmic rays, so the problem is now handed to you. However, you do not need to compute the worst-case scenario that could occur. You only need to solve the original problem.

Description

You are given a sequence $a$ of length $n$. Find the sum of the bitwise OR sums over all subintervals.

Input Format

**This problem uses a special input method. Below is the [input template](https://www.luogu.com.cn/paste/rz2t978c):** ```cpp #include #define Misaka namespace #define Mikoto std #define ull unsigned long long using Misaka Mikoto; namespace READ { ull Read() { char ch=getchar(); ull s=0; while(ch'9') ch=getchar(); while(ch>='0'&&ch

Output Format

Output one integer, representing the answer. The answer is taken modulo $2^{64}$.

Explanation/Hint

It is guaranteed that the input template takes less than 200 ms in time and less than 1 MB in memory. ### Constraints This problem uses bundled testdata. | $\text{Subtask}$ | $n\le$ | $\text{Score}$ | | :----------: | :----------: | :----------: | | $1$ | $10^4$ | $10$ | | $2$ | $3\times 10^6$ | $20$ | | $3$ | $4\times 10^7$ | $30$ | | $4$ | $5\times 10^7$ | $40$ | For $100\%$ of the testdata, $1\le n\le 5\times 10^7$ and $0\le a_i