#P1974C. Beautiful Triple Pairs
Beautiful Triple Pairs
No submission language available for this problem.
Description
Polycarp was given an array of integers. He really likes triples of numbers, so for each () he wrote down a triple of elements .
Polycarp considers a pair of triples and beautiful if they differ in exactly one position, that is, one of the following conditions is satisfied:
- and and ;
- and and ;
- and and .
Find the number of beautiful pairs of triples among the written triples .
The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of the array .
The second line of each test case contains integers () — the elements of the array.
It is guaranteed that the sum of the values of for all test cases in the test does not exceed .
For each test case, output a single integer — the number of beautiful pairs of triples among the pairs of the form .
Note that the answer may not fit into 32-bit data types.
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 length of the array .
The second line of each test case contains integers () — the elements of the array.
It is guaranteed that the sum of the values of for all test cases in the test does not exceed .
Output
For each test case, output a single integer — the number of beautiful pairs of triples among the pairs of the form .
Note that the answer may not fit into 32-bit data types.
Note
In the first example, , Polycarp will write the following triples:
- ;
- ;
- .
In the third example, , Polycarp will write the following triples:
- ;
- ;
- ;
- ;
- ;
- ;