n log n count inversions