Java Simple Stack Solution
\nclass Solution {\n    public int maxSumMinProduct(int[] nums) {\n        Stack<Long> st  = new Stack<Long>();\n        Stack<Long> cnt = new Stack<Long>();\n 
```\nclass Solution {\n    public int maxSumMinProduct(int[] nums) {\n        Stack<Long> st  = new Stack<Long>();\n        Stack<Long> cnt = new Stack<Long>();\n        long max = 0,c = 0;\n        final int MOD = 1_000_000_007;\n        \n        for(int i=0;i<nums.length;++i){\n            c = nums[i];\n            while(!st.isEmpty() && st.peek() >= nums[i]){\n                c += cnt.pop();\n                max = Math.max(max,(c - nums[i]) * st.pop());\n            }\n            \n            st.push((long)nums[i]);\n            cnt.push(c);\n            max = Math.max(max,c * nums[i]);\n        }\n        \n        c = 0;\n        while(!st.isEmpty()){\n            c += cnt.pop();\n            max = Math.max(max,c * st.pop());\n        }\n        \n        return (int)(max % MOD);\n    }\n}\n```
[]