Odoo has introduced its new POS Kiosk app, which allows restaurants to receive orders from clients in their shop and process them easily. So basically, there are 2 main functionalities of the POS kiosk: add order , mark order as done so it's removed from the screen.
For performance reasons, the updates in the database are made in batches. It means that for each batch of updates, there is only one query executed to remove/add records to the database.
To test the database performance, Odoo developers came up with the following process :
Given the generated array $$$A$$$, can you simulate the experiment and find : $$$$$$\sum_{1\leq L \leq R\leq n}f(A,L,R)$$$$$$
The first line contains an integer $$$T$$$ $$$(1 \leq T \leq 2 \cdot 10^{5})$$$, the number of testcases.
For each test case:
The first line contains an integer $$$n$$$ $$$(1 \leq n \leq 2 \cdot 10^{5})$$$, the size of the generated array of updates.
The second line contains $$$n$$$ integers $$$A_{i}$$$ $$$(-2 \cdot 10^3 \leq A_{i} \leq 2\cdot 10^{3})$$$, the data of the generated array.
The sum of $$$n$$$ over all test cases doesn't exceed $$$2\cdot 10^{5}$$$
Print $$$T$$$ lines where the $$$i_{th}$$$ line contains the answer for the $$$i_{th}$$$ testcase.
23-2 3 -571 -2 3 4 5 -10 223
8 1672
Explanation of the first test case:
The total sum is equal to $$$8$$$
| Name |
|---|


