Java, No Stack, Beats 100%
We can borrow the idea from largest histogram. Using skip array technique to find index faster\nhere is code\n\nclass Solution {\n    public int maxSumMinProduc
We can borrow the idea from largest histogram. Using skip array technique to find index faster\nhere is code\n```\nclass Solution {\n    public int maxSumMinProduct(int[] nums) {\n        int n = nums.length;\n        long[] prefixSum = new long[n + 1];\n        for (int i = 1; i <= n; i++) { // prefix Sum\n            prefixSum[i] = prefixSum[i - 1] + nums[i - 1];\n        }\n        int[] left = new int[n];\n        int[] right = new int[n];\n        for (int i = 0; i < nums.length; i++) {\n            int index = i - 1;\n            while (index >= 0 && nums[index] >= nums[i]) { // this is key part\n                index = left[index];\n            }\n            left[i] = index;\n        }\n        for (int i = nums.length - 1; i >= 0; i--) {\n            int index = i + 1;\n            while (index < nums.length && nums[index] >= nums[i]) {\n                index = right[index];\n            }\n            right[i] = index;\n        }\n        long max = 0;\n        for (int i = 0; i < n; i++) { // make current element as Min value\n            int l = left[i];\n            int r = right[i];\n            long sum = prefixSum[r] - prefixSum[l + 1];\n            long prod = sum * nums[i];\n            max = Math.max(prod, max);\n        }\n        return (int)(max % 1_000_000_007);\n    }\n}\n```
[]