count array inversions