Given an array of integers, construct a tree. Each node of the tree has either two children or none, in which case it is a leaf node. A leaf node costs 0 to construct. The cost to build a parent node is the product of the maximum leaf values in its left and right sub-trees. Partition the array to minimize the cost of building the entire tree.