Problems
Sum of leaves
Sum of leaves
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 all leaves in a tree.
\InputFile
The first line contains number $n~(1 \le n \le 1000)$. The second line contains $n$ integers.
\OutputFile
Create the Binary Search Tree from input data. Print the sum of all leaves in a tree.
\Examples
\includegraphics{https://static.e-olymp.com/content/15/15e10dd59d19107d5f36f26a53af32eb9c13fce0.gif}
The sum of leaves equals to $1 + 5 + 11 = 17$.
Input example #1
7 7 3 5 7 1 11 1
Output example #1
17