题目描述
Mr. Smoothy is a restaurant that serves mostly smoothies at which Ben and his friends are regular customers. The titular mascot is a cup with face and legs that holds a smaller cup. It serves the strangest assortment of flavors in its smoothies, made to order.
The restaurant was about to open, and there was crowd gathered around the serving window. Ben was also there. As the window opens, crowd quickly makes a line. Unfortunately Ben gets the last place. He complains that he came before many others in the line, so he should be served before them.
Similarly, many others who are standing at the back of the line start complaining.
Your task is to count number of complaints made by all. Ignore that Ben is a hero this time. Also, many persons can arrive together, so they cannot complain for each other.
INPUT
First line of input is T,the number of test cases.
T test cases follow.
First integer is N, the number of persons standing in line, including Ben.
N integers follow, in the same sequence in which line is formed. Every integer denotes the arrival order of that person, value 1 being first to arrive at Mr. Smoothy and so on.
OUTPUT
For each test case, print the number of complaints made.
CONSTRAINTS
1 ≤ T ≤ 20
1 ≤ N ≤ 100
1 ≤ Arrival order ≤ 1000
SAMPLE INPUT
1
5 5 6 3 4 8
SAMPLE OUTPUT
4
Explanation
Here, 8 cannot make a complaint, 4 makes 2 complaints for 5 and 6, 3 also does the same, logging 2 more complaints, hence the output.
输入格式
见题面
输出格式
见题面