------
## 最终结论
```python
def minNonLeafSum(arr):
    res = 0
    stack = [float('inf')]
    
    for a in arr:
        while stack[-1] <= a:
            mid = stack.pop()
            res += mid * min(stack[-1], a)
        stack.append(a)
    
    while len(stack) > 2:
        res += stack.pop() * stack[-1]
        
    return res

# Example usage:
arr = [6, 2, 4]
print(minNonLeafSum(arr))  # Output: 32
```