Python
python\n        nums.append(0)\n        stack, res = [], 0\n        for i, n in enumerate(nums):\n            accu = 0\n            while stack and stack[-1][0]
```python\n        nums.append(0)\n        stack, res = [], 0\n        for i, n in enumerate(nums):\n            accu = 0\n            while stack and stack[-1][0] > n:\n                x, y = stack.pop()\n                accu += y\n                res = max(res, x * accu)\n            stack.append((n, n + accu))\n        return res % (10**9+7)\n```
['Python']