Python Monotonic Stack
Add each number + its index to the stack while iterating through nums.\n - pop all values greater than the current value from the stack (its the end of a subarr
- Add each number + its index to the stack while iterating through `nums`.\n - pop all values greater than the current value from the stack (its the end of a subarray that we need to calculate)\n - when pushing to the stack, use either the current index, or the earliest index of numbers that were greater than the current number (that we popped from the stack)\n\n```\nclass Solution:\n    def maxSumMinProduct(self, nums: List[int]) -> int:\n        ps = [0] + list(accumulate(nums))\n        stack, ans = [], 0\n        for i, num in enumerate(nums + [-inf]):\n            j = i\n            while stack and num < stack[-1][0]:\n                lo, j = stack.pop()\n                ans = max(ans, lo * (ps[i] - ps[j]))\n            stack.append((num, j))\n        return ans % (10**9 + 7)\n```
[]