C# Using Stack 100% Similar to Largest Rectangle in Histogram
\npublic class Solution {\n    public int MaxSumMinProduct(int[] nums) {\n        \n        //*** Method 1 : Using Monotonic Increasing Stack ***//\n        var
```\npublic class Solution {\n    public int MaxSumMinProduct(int[] nums) {\n        \n        //*** Method 1 : Using Monotonic Increasing Stack ***//\n        var MOD = 1000000007;\n        long res = 0;       \n        int n = nums.Length;\n        var st = new Stack<int>();\n        var preSum = new long[n + 1];\n        for (int i = 0; i < nums.Length; ++i)\n           preSum[i + 1] = preSum[i] + nums[i];\n        \n        for (int i = 0; i <= n; i++) {\n            while (st.Count > 0 && (i == n || nums[st.Peek()] > nums[i])) {\n                int j = st.Pop();                \n                res = Math.Max(res, nums[j] * (preSum[i] - preSum[st.Count == 0 ? 0 : st.Peek() + 1]));\n            }\n            st.Push(i);\n        }\n        return (int)(res % MOD);\n    }\n}\n```
[]