Consider having two stacks of integers, one loaded with some distinct integers and the other empty. The following operation is performed until both stacks become empty:
For a sequence $$$S$$$ of distinct integers, define $$$f(S)$$$ as the number of operations performed if the first stack is loaded with $$$S$$$.
Given a permutation $$$p$$$ of length $$$n$$$, compute the sum of $$$f(S)$$$ over all non-empty subsequences $$$S$$$ of $$$p$$$.
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$).
The second line contains $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$. It is guaranteed that $$$p$$$ is a permutation of $$$1$$$ to $$$n$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, print a single integer on a new line, the sum of $$$f(S)$$$ over all non-empty subsequences $$$S$$$ of $$$p$$$ modulo $$$10^9+7$$$.
532 3 142 4 1 354 1 3 5 221 273 5 4 7 1 6 2
14 44 121 5 734
| Name |
|---|


