Staircase Patterns#4073

Staircase Patterns

1 second
128 megabytes
Very easy (≈850)

One day, you come across an interesting staircase with a number written on each step. Curious about these numbers, you decide to look at all of them as you climb. For each step, you write down the sum of all numbers on the previous steps that are smaller than the number on the current step. At the end, you want to know the total of all the sums you have written down.

Formally, given a sequence a_1, a_2, \ldots, a_n, find

\sum_{i = 1}^{n} \sum_{\substack{j < i \\ a_j < a_i}} a_j

Input

The first line contains an integer t~(1 \le t \le 10) — the number of test cases.

Each test case consists of two lines. The first line contains an integer n~(1 \le n \le 10^5) — the number of steps. The second line contains integers a_1, a_2, \ldots, a_n~(0 \le a_i \le 10^6) — the numbers written on the steps, in the order you climb.

Output

For each test case, print the total sum on a separate line.

Examples

Example 1

Loading
Loading