Given arr, build a binary tree whose leaves are arr in order (in-order). Each internal node's value is the product of the largest leaf in its left subtree and the largest leaf in its right subtree. Return the minimum possible sum of all internal node values. The input is JSON {arr}.
Input: JSON {arr}.
Output: Integer — the minimum sum of internal node values.
Input: {"arr":[6,2,4]}
Output: 32
Explanation: An optimal tree sums to 32.Input: {"arr":[1,2,3,4]}
Output: 20
Explanation: Optimal internal sum.Input: {"arr":[7,12]}
Output: 84
Explanation: Single internal node.2<=n<=40