Count Inversions in an Array