Do you know bubble sort algorithm? It's one of the most famous sorting algorithms.
The bubble sort algorithm is stable, which can be described below:
It's easy for us to find that we need swap
%5Ccdot(n-2)%5Ccdots2%5Ccdot1)
times in the worst case, so the total swapping count is about
)
, where n is the length of the given sequence.
But the above result is an approximate result. As a curious student, Ramen is wondering, among all permutations of length n, what the value of the average
exact swap count is?
输入描述:
The input contains multiple test cases.
The first line is an integer T(1 <= T <= 10000), which indicates represents the number of test cases.
Each of the next T lines contains an integer n(1 <= n <= 1e18), represents the length of the permutation.
输出描述:
For each test case, output the average swap count in one single line.
To avoid possible errors, if the answer is
, you need to output
, i.e.,
, where
is the minimum number that suits
.