C++ / increasing mono stack / simple solution with explanation
We maintain a mono increasing stack and using a trick that add 0 to nums.\nAlso, we maintain a prefix sum psum[i] that can make us easily find any subarray sum 
We maintain a mono increasing stack and using a trick that add `0` to `nums`.\nAlso, we maintain a prefix sum `psum[i]` that can make us easily find any subarray sum `nums[i...j]`.\n\nSo when we process `nums` and if `nums[sk.back()] > nums[i]` by checking top of stack , we know that there is a subarray starting from index `sk.back()` to `i-1` that `nums[sk.back()]` is minimum. \n\nSo the sum from `sk.back() ... i-1` can be calculate by `sum = psum[i-1] - psum[sk.back()]` , and the subarray min-product is `sum * nums[sk.back()]`\n \n* time: `O(n)`\n* space: `O(n)`\n```\nclass Solution {\npublic:\n    using ll = long long;\n    int maxSumMinProduct(vector<int>& nums) {\n        int n = nums.size(), mod = 1e9+7;\n        vector<ll> psum = {nums[0]};\n        for (int i = 1; i < n; ++i) {\n            psum.push_back(psum.back()+nums[i]);\n        }\n        ll res = 0;\n        vector<int> sk;\n        nums.push_back(0);\n        ++n;\n        for (int i = 0; i < n; ++i) {\n            while (sk.size() && nums[sk.back()] > nums[i]) {\n                int idx = sk.back();\n                sk.pop_back();\n                ll lsum = sk.size() ? psum[sk.back()] : 0;\n                res = max(res, (psum[i-1]-lsum)*nums[idx]);\n            }\n            sk.push_back(i);\n        }\n        return res%mod;\n    }\n};\n```
[]