Problems
Sum of nodes in a subtree
Sum of nodes in a subtree
Given an array of integers. Create a Binary Search Tree from these numbers. If the number is already in the tree, do not insert it (no duplicates).
Find the sum of nodes in the specified subtree.
\InputFile
The first line contain numbers $n~(1 \le n \le 1000)$ and $v~(0 \le v \le 10000)$. The second line contains $n$ integers.
\OutputFile
Create the Binary Search Tree from input data. Print the sum of all nodes in the subtree with root in $v$. If vertex $v$ is not present in the tree, print $-1$.
\Examples
\includegraphics{https://static.e-olymp.com/content/9b/9bdbdfbc1506716468444de1c26ca19d6df353a8.gif}
The sum of nodes in the subtree with root $5$ equals to $4 + 5 + 7 = 16$.
Input example #1
11 5 9 3 11 5 10 7 16 1 4 3 10
Output example #1
16