For this Question: Given an integer array nums of size n, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i].Implement the given function.

Constraints:
1 <= n <= 10^5
1 <= nums[i] <= 10^9Return the count array.Input:
4
5 2 6 1

Output:
2 1 1 0, I have written this Solution Code: class Node:
	def __init__(self,val):
		self.val = val
		self.left = None
		self.right = None
		self.elecount = 1
		self.lcount = 0

class Tree:
	def __init__(self,root):
		self.root = root
	def insert(self,node):
		curr = self.root
		cnt = 0
		while curr!=None:
			prev = curr
			if node.val>curr.val:
				cnt += (curr.elecount+curr.lcount)
				curr=curr.right
			elif node.val<curr.val:
				curr.lcount+=1
				curr=curr.left
			else:
				prev=curr
				prev.elecount+=1
				break
		if prev.val>node.val:
			prev.left = node
		elif prev.val<node.val:
			prev.right = node
		else:
			return cnt+prev.lcount
		return cnt
def constructArray(arr,n):
	t = Tree(Node(arr[-1]))
	ans = [0]
	for i in range(n-2,-1,-1):
		ans.append(t.insert(Node(arr[i])))
	return reversed(ans)
n=int(input())
arr = list(map(int,input().split()))
print(" ".join(list(map(str,constructArray(arr,n))))), In this Programming Language: Python, Now tell me if this Code is compilable or not?