This problem can be solved by sorting:
We will do insertion sort with binary search to find the place to insert, we need to record 2 things for each number:
C2-C1
is the number of smaller element after N
But we need to output the counts in original sequence, this can be done by carrying the original index with the number, and finally sorting by this index.