Staircase Patterns#4073

Staircase Patterns

1 sekunt
128 megabaýt
Örän ýeňil

One day, you come across an interesting staircase. On each step, there is a number written. Curious about the sequence, you decide to observe all the numbers as you climb. Soon, you notice a pattern: for each number on the step, you record the sum of all previously encountered numbers that are smaller than the current one.

Giriş

The first line contains an integer (t \le 10) — the number of test cases. The next lines follow. The first of these lines contains an integer (1 \le n \le 10^5) — the number of steps. The next line contains integers — the numbers written on the steps. All numbers are in the range from to 10^6.

Çykyş

For each test case, print the final sum in a separate line.

Mysallar

1-nji mysal

Loading
Loading