[C++/Python 3] Monostack, explanation with picture, O(N) Time
For each number nums[i] in nums, we calculate how many consecutive numbers no less than nums[i] are on its left lft and on its right rgt. \n\nThen, the Min-Prod
For each number ```nums[i]``` in nums, we calculate how many **consecutive** numbers **no less** than ```nums[i]``` are on its left ```lft``` and on its right ```rgt```. \n\nThen, the Min-Product for **this number nums[i]** equals to the ```nums[i] * (lft + rgt + 1)```, since ```lft``` and ```rgt``` are calculated excluse ```nums[i]```, we have to add ```1``` to the total number standing for ```nums[i]``` itself.\n\nTake the picture below as an example.\n![image](https://assets.leetcode.com/users/images/cf7317b7-e276-4151-9af4-0273585c588c_1620532928.1806393.png)\nFor ```nums[3]```, we can find ```2``` numbers on its left (starting from ```nums[3]``` exclusively) which are no less than ```nums[3]```, and ```1``` number on its right exclusively, so the **segment with minimum number of nums[3] has length of 2 + 1 + 1 = 4**, this can be done by keeping a monotonic array.\n\n\n![image](https://assets.leetcode.com/users/images/f6a14899-5dfb-446f-affe-7244d1004fa0_1620532938.484092.png)\nThe sum of subarray can be done by getting the presum array of ```nums```, and the Min-product is ```nums[i] * presum[i + rgt + 1] - presum[i - lft]```\n\n#### Python 3\n```\ndef maxSumMinProduct(self, nums: List[int]) -> int:\n        n, ans, mod = len(nums), 0, 10 ** 9 + 7\n        \n        lft, st = [0], [[nums[0], 0]]       #how many valid numbers on its left \n        for i in range(1, n):\n            cur = 0\n            while st and nums[i] <= st[-1][0]:\n                cur += st.pop()[1] + 1\n            st.append([nums[i], cur])\n            lft.append(cur)\n\n        rgt, st = [0], [[nums[-1], 0]]               #how many valid numbers on its right \n        for i in range(n - 2, -1, -1):\n            cur = 0\n            while st and nums[i] <= st[-1][0]:\n                cur += st.pop()[1] + 1\n            st.append(([nums[i], cur]))\n            rgt.append(cur)\n        rgt.reverse()\n\n        sums, cur = [0], 0           # presum array\n        for i in range(n):\n            cur += nums[i]\n            sums.append(cur)\n\n        for i in range(n):\n            ans = max(ans, nums[i] * (sums[i + rgt[i] + 1] - sums[i - lft[i]]))\n\n        return ans % mod\n```\n\n#### cpp\n```\npublic:\n    int maxSumMinProduct(vector<int>& nums) {\n        int mod = 1000000007;\n        int n = nums.size();\n        int lft[n], rgt[n];\n        long long int sum[n + 1];\n        sum[0] = 0;\n        for (int i = 1; i < n + 1; i++)\n        {\n            sum[i] = sum[i - 1] + nums[i - 1];\n        }\n\n        stack<pair<int, int>> s1, s2;        \n        lft[0] = 0;\n        s1.push({nums[0], 0});\n        for (int i = 1; i < n; i++)\n        {\n            int cur = 0;\n            while(!s1.empty() && (s1.top().first) >= nums[i])\n            {\n                cur += s1.top().second + 1;\n                s1.pop();\n            }\n            s1.push({nums[i], cur});\n            lft[i] = cur;\n        }\n        \n        rgt[n - 1] = 0;\n        s2.push({nums[n - 1], 0});\n        for (int i = n - 2; i > -1; i--)\n        {\n            int cur = 0;\n            while(!s2.empty() && (s2.top().first) >= nums[i])\n            {\n                cur += s2.top().second + 1;\n                s2.pop();\n            }\n            s2.push({nums[i], cur});\n            rgt[i] = cur;\n        }\n\n        long long int ans = 0;\n        for (int i = 0; i < n; i++)\n        {\n            ans = max(ans, nums[i] * (sum[i + rgt[i] + 1] - sum[i - lft[i]]));\n        }\n        return ans % mod;           \n    }\n```
[]