The problem is equal to find each number's inversion count. Actually there are three kinds of solutions: BST, mergeSort, and BITree. While the first two answer's time complexity is O(n*logn), and BITree time comlexity is O( n*log(maximumNum) ).

Actually we use the BITree to trace the total count of each position from [0-maximum] like a RadixSort. When we at index i, we want to find the smaller num's total count in range [i+1, n-1]. First, we find the maximum num in the array, and create a BITree length(maximum). After init, we could iterate the array from n-1 to 0, each time we could find the smaller num's total count using the BITree's sumRange function, add one to the num[i] position using BITree's update function. Each operation is O(log(maximum)), thus the total complexity will be O( n*log(maximumNum) ).

Well, in this problem, there might be minus numbers in the array, we could add a padding num which equal to the minimum number in the array.

Finally the code:

```
class Solution(object):
def getSum(self, T, idx):
ans = 0
while idx:
ans += T[idx]
idx -= idx & (-idx)
return ans
def update(self, T, idx, val):
while idx <= len(T)-1:
T[idx] += val
idx += idx & (-idx)
def countSmaller(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
if not nums:
return []
n = len(nums)
padding = min(nums)
if padding <= 0:
nums = [a + 1 - padding for a in nums]
m = max(nums)
T = [0] * (m+1)
ans = []
t = 0
for num in nums[::-1]:
ans.append(self.getSum(T, num-1))
self.update(T, num, 1)
return ans[::-1]
```

BTW: This is my first time answer a question, and wish my poor English could explain that clearly. I'll be glad to receive your reply which including any grammar problem either. ^_^