Easy C++ | Solution
````\nclass Solution {\npublic:\n    int maxSumMinProduct(vector& nums) {\n        \n        // take every element as minimum and calculate the min product till
````\nclass Solution {\npublic:\n    int maxSumMinProduct(vector<int>& nums) {\n        \n        // take every element as minimum and calculate the min product till left and right smaller element\n        int n=nums.size();\n        vector<int>left_smaller(n,-1);\n        vector<int>right_smaller(n,n);\n        vector<long long>prefix_sum(n,0);\n        long long ans=INT_MIN;\n        int mod=1e9+7;\n        \n        stack<int>st;\n        \n        \n        // left smaller \n        for(int i=0;i<n;i++)\n        {\n            while(!st.empty() && nums[st.top()]>=nums[i])\n            {\n                st.pop();\n            }\n            if(st.empty())\n            {\n                left_smaller[i]=-1;\n            }\n            else\n            {\n                left_smaller[i]=st.top();\n            }\n            st.push(i);\n        }\n        \n        while(!st.empty())st.pop();\n        \n        // right smaller\n        for(int i=n-1;i>=0;i--)\n        {\n            while(!st.empty() && nums[st.top()]>=nums[i])\n            {\n                st.pop();\n            }\n            if(st.empty())\n            {\n                right_smaller[i]=n;\n            }\n            else\n            {\n                right_smaller[i]=st.top();\n            }\n            st.push(i);\n        }\n        \n        // find prefix sum\n        prefix_sum[0]=nums[0];\n        for(int i=1;i<n;i++)\n        {\n            prefix_sum[i]=prefix_sum[i-1]+nums[i];\n        }\n        \n        // calculating maximum subarray min-product\n        for(int i=0;i<n;i++)\n        {\n            long long left=(left_smaller[i]==-1)?0:prefix_sum[left_smaller[i]];\n            long long right=prefix_sum[right_smaller[i]-1];\n            \n            long long curr=((right-left)*nums[i]);\n            ans=max(ans,curr);\n            \n        }\n        return ans%mod;\n        \n    }\n};
['Stack']