An inversion in an array is a pair of positions where the earlier element is the bigger one, that is . A sorted array has no inversions at all, and an array sorted the wrong way round has as many as there are pairs - so the number of inversions is a measure of how far from sorted an array is.
Your task is to count them.
Input
First line of input will be a single integer - the number of testcases.
The first line of each testcase contains a single integer - the length of the array.
The second line contains integers .
Output
For every testcase print a single line with the number of inversions in that array.
Example
2 5 3 1 4 2 5 4 4 3 2 1
3 6
The first array has three inversions: the pairs , and . The second one is sorted in reverse, so every one of its pairs is an inversion.
Constraints
The sum of over all testcases does not exceed
This problem was adapted, with permission, from Broj inverzija, authored by Društvo matematičara Srbije and Fondacija Petlja.