inversion count broken for special cases