#P1400D. Zigzags
Zigzags
No submission language available for this problem.
Description
You are given an array . Calculate the number of tuples such that:
- ;
- and ;
The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the size of the array .
The second line of each test case contains integers () — the array .
It's guaranteed that the sum of in one test doesn't exceed .
For each test case, print the number of described tuples.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the size of the array .
The second line of each test case contains integers () — the array .
It's guaranteed that the sum of in one test doesn't exceed .
Output
For each test case, print the number of described tuples.
Samples
Note
In the first test case, for any four indices are valid, so the answer is the number of tuples.
In the second test case, there are valid tuples:
- : and ;
- : and .