Compute the number of inversions in a seq