For example, suppose that A = (20, 43, 57, 43, 20). For the fourth day's sales amount, a4 = 43, the number of previous days whose sales amounts are less than or equal to it is 2 since a1 ≤ a4, a2 ≤ a4, and a3 > a4. Therefore, b3 = 2. Similarly, b1, b2, and b4 can be obtained and it results in B = (1, 2, 2, 1).
Given an array of size n for the list of daily sales amounts, write a program that prints the sum of the n − 1 integers in the list B.
Your program is to read the input from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case starts with a line containing an integer n (2 ≤ n ≤ 1, 000), which represents the size of the list A . In the following line, n integers are given, each represents the daily sales amounts ai (1 ≤ ai ≤ 5, 000 and 1 ≤ i ≤ n) for the test case.
Your program is to write to standard output. For each test case, print the sum of the n − 1 integers in the list B which is obtained from the list A.
The following shows sample input and output for two test cases.