Solve CountInversions.