Python || Clean Monotonic Stack Solution
python\nfrom collections import deque\nfrom itertools import accumulate, chain\nfrom math import inf\n\nMAX = 10 ** 9 + 7\n\n\nclass Solution:\n    def maxSumMi
```python\nfrom collections import deque\nfrom itertools import accumulate, chain\nfrom math import inf\n\nMAX = 10 ** 9 + 7\n\n\nclass Solution:\n    def maxSumMinProduct(self, A: list[int]) -> int:\n        """\n        @also see https://leetcode.com/problems/maximum-subarray-min-product/solutions/1198800/python3-mono-stack/\n        :param A: \n        :return: \n        """\n        # prefix_sum[i] = sum(A[:i])\n        prefix_sum = [*accumulate(A, initial=0)]\n\n        # creating monotonic increasing stack\n        push, pop = (stk := deque()).append, stk.pop\n\n        output = 0\n\n        for i, a in enumerate(chain(A, [-inf])):\n            while stk and A[stk[-1]] >= a:\n                mn = A[pop()]\n\n                j = stk[-1] if stk else -1\n\n                output = max(\n                    output,\n                    mn * (prefix_sum[i] - prefix_sum[j + 1])  # mn * sum(A[j: i])\n                )\n\n            push(i)\n\n        return output % MAX\n\n```
['Monotonic Stack', 'Python3']