C++ simple solution using stacks || Explained!!
The main idea is \n  As we want to find min-product, calculating minimum number from all sub arrays gives us TLE\n  So what we do is, we consider nums[i] where 
The main idea is \n*  As we want to find min-product, calculating minimum number from all sub arrays gives us **TLE**\n*  So what we do is, we consider `nums[i]` where `0<=i< n`, as min element and find the min-products of subarrays with minimum as `nums[i]`.\n* First we find the `prefix sum` of given array.\n*  Then we find the **number of largest numbers** to the left in "array left" and number of largest numbers to the right in  "array right" with `nums[i]` as minimum.\n*  After finding that, now its become simple, as we know the length of sub array with `nums[i]` as minimum.\n* To get starting index a, `a = i-left[i]+1`, and ending index `b = i+right[i]-1`.\n*  Then process the `res`, as we know the sum of subarray as we have `prefix sum` and minimum element is `nums[i]`.\n*  Update the `res` by finding `maximum of min-product`.\n\n\n**DO UPVOTE if you fnd it helpful!!**\n```\nint maxSumMinProduct(vector<int>& nums) {\n        int n = nums.size();\n        int left[n], right[n];\n        long long int sum[n];\n        sum[0] = nums[0];\n        for(int i=1;i<n;i++){\n            sum[i] = sum[i-1]+nums[i];\n        }\n        stack<pair<int, int> > s1, s2;\n        for (int i = 0; i < n; ++i) {\n            int cnt = 1;\n            while (!s1.empty() && (s1.top().first) > nums[i]) {\n                cnt += s1.top().second;\n                s1.pop();\n            }\n            s1.push({ nums[i], cnt });\n            left[i] = cnt;\n        }\n        for (int i = n - 1; i >= 0; --i) {\n            int cnt = 1;\n            while (!s2.empty() && (s2.top().first) >= nums[i]) {\n                cnt += s2.top().second;\n                s2.pop();\n            }\n\n            s2.push({ nums[i], cnt });\n            right[i] = cnt;\n        }\n        long long int res =0;\n        for(int i=0;i<n;i++){\n            int a = i-left[i]+1;\n            int b = i+right[i]-1;\n            long long int subArraySum;\n            if(a>0)\n                subArraySum = sum[b]-sum[a-1];\n            else\n                subArraySum = sum[b];\n            res = max(res, subArraySum*nums[i]);\n        }\n        return res%1000000007;\n    }\n```\n**Any improments in the code is highly encouraged!! Comment down below !!**
[]