Given a permutation$$$^{\dagger}$$$ $$$a$$$ of size $$$n$$$, with elements from $$$1$$$ to $$$n$$$.
Let's define the strength of an array $$$a$$$ of size $$$k$$$ (given all elements are distinct) as follows:-
Find the sum of the strength of all the non-empty subarrays of $$$a$$$.
$$$^{\dagger}$$$Permutation of size $$$k$$$ is an array which contains all integers from $$$1$$$ to $$$k$$$.
Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1\leq t \leq 5\cdot 10^4$$$). The following line contains the description of each test case.
The first line contains two integers $$$n$$$ ($$$1\leq n \leq 10^6$$$) — the size of the array.
The second line contains $$$n$$$ positive integers $$$a_1$$$, $$$a_2$$$, $$$a_3$$$, $$$...$$$ ,$$$a_n$$$ ($$$1 \leq a_i \leq n$$$) — elements of the array $$$a$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$.
Print a single integer representing the sum of the strength of all the non-empty subarrays of $$$a$$$.
31132 1 343 4 1 2
1 9 14
For the second test case,
| Name |
|---|


