//誤解法(O(N^2)愚直解)チェック ll@T;rep(T){ll@N,a=0;listA;fenwickt;t.malloc(N+1,1);rep(i,N){ll@P,c=t.range(0,P);if(c>i-c||A.empty())a+=i-c,A.push_back(P);else if(c