Python monotonic stack beats 100%
a monotonic stack with index and prefix sum\n\n```\nclass Solution:\n    def maxSumMinProduct(self, nums: List[int]) -> int:\n        mod=int(1e9+7)\n        st
a monotonic stack with index and prefix sum\n\n```\nclass Solution:\n    def maxSumMinProduct(self, nums: List[int]) -> int:\n        mod=int(1e9+7)\n        stack=[] # (index, prefix sum at index)\n        rsum=0\n        res=0\n        \n        nums.append(0)\n        \n        for i, v in enumerate(nums):\n            while stack and nums[stack[-1][0]] >= v:\n                index, _ = stack.pop()\n\t\t\t\t\n\t\t\t\t# if the stack is empty, the subarray sum is the current prefixsum\n                arrSum=rsum\n                \n                if stack:\n                    arrSum=rsum-stack[-1][1]\n                \n\t\t\t\t# update res with subarray sum\n                res=max(res, nums[index]*arrSum)\n                \n            rsum+=v\n            stack.append((i, rsum))\n        \n        return res%mod
['Monotonic Stack', 'Python', 'Python3']