monotonic stack + prefix sum
\nclass Solution:\n    def maxSumMinProduct(self, nums: List[int]) -> int:\n        Point = namedtuple(\'Point\', [\'val\', \'prefix\'])\n        stack = [Point
```\nclass Solution:\n    def maxSumMinProduct(self, nums: List[int]) -> int:\n        Point = namedtuple(\'Point\', [\'val\', \'prefix\'])\n        stack = [Point(-1, 0)]\n        maxval = 0\n        for n in nums:\n            if n > stack[-1].val:\n                stack.append(Point(n, stack[-1].prefix+n))\n            else:\n                prev_prefix = stack[-1].prefix\n                while n < stack[-1].val:\n                    point = stack.pop()\n                    maxval = max(maxval, (prev_prefix - stack[-1].prefix) * point.val)\n                stack.append(Point(n, prev_prefix+n))\n        \n        prev_prefix = stack[-1].prefix\n        while stack[-1].val != -1:\n            point = stack.pop()\n            maxval = max(maxval, (prev_prefix - stack[-1].prefix) * point.val)\n            \n        return maxval % (10**9+7)\n```\nThis is almost the exact same question as `84. Largest Rectangle in Histogram ` except that you have to compute the prefix sum instead of using just the indices/width
[]