All N students of a class are standing on a straight line behind one other student. For example, student 2 is standing behind student 1, student 3 is standing behind student 2, and so on until the Nth student.
The happiness level of a student is determined by the number of students standing before him whose height is strictly greater than him. The total happiness of the class is the sum of the happiness level of all students.
Now you can help minimize this sadness. Your task is to minimize the happiness level of the class.
Note: You can select one student from anywhere in the line and place him at the end of the line.
Input format
Output format
For each test case, print the minimum total happiness that can be achived.
Constraints
1≤T≤51≤N≤1051≤height≤1010
Place the first student at end of line
so the new line becomes
1 3 2 4
clearly total sadness level = ( 0 + 0 + 1 + 0 ) = 1 .