You are given an integer array \(A\). Your task is to calculate the sum of absolute difference of indices of first and last occurrence for every integer that is present in array \(A\).
Formally, if element \(x\) occurs \(m\) times in the array at indices \(B_1,\ B_2,\ B_3,\ ...,B_m\), then the answer for \(x\) will be \(B_m-B_1\) if array \(B\) is sorted.
You are required to calculate the sum of the answer for every such \(x\) that occurs in the array.
Refer to sample notes and explanations for better understanding.
Input format
- The first line contains an integer \(T\) that denotes the number of test cases.
- The first line of each test case contains an integer \(x\) that denotes the number of elements in the array.
- The second line of each test case contains \(x\) space seperated integers \(A_1,\ A_2,\ A_3,\ ...,A_n\).
Output format
For each test case, print a single line as described in the problem statement.
Constraints
\(1 \leq T \leq 1000 \)
\(1 \leq N \leq 200000\)
\(1 \leq A_i \leq 1e9 \forall i \in [0,n-1]\)
The sum of \(N\) over all test cases will not exceed 200000.