Most Efficient Solution C++
\n int maxSumMinProduct(vector<int>& nums) {\n      vector<long>preSum, left(nums.size(), -1), right(nums.size(), nums.size());\n     int n = nums.size();\n    
```\n int maxSumMinProduct(vector<int>& nums) {\n      vector<long>preSum, left(nums.size(), -1), right(nums.size(), nums.size());\n     int n = nums.size();\n     preSum.push_back(0);\n\t \n\t //Getting perfix sum of given array to reduce complexity by avoiding recalculation \n     for (int i = 0; i < nums.size(); i++)\n        preSum.push_back(preSum.back() + nums[i]);\n\n    // Storing previous smaller element index in left array\n\t stack<int>st;\n     for (int i = 0; i < nums.size(); i++) {\n     while (!st.empty() && nums[i] <= nums[st.top()])\n        st.pop();\n     if (!st.empty())\n        left[i] = st.top();\n     st.push(i);\n  }\n   // Storing next smaller element index in right array\n  st = stack<int>();\n     for (int i = nums.size() - 1; i >= 0; i--) {\n\t\t  while (!st.empty() && nums[i] <= nums[st.top()])\n\t\t  st.pop();\n    if (!st.empty())\n\t\t  right[i] = st.top();\n    st.push(i);\n  }\n\n  long ans = 0, mod = 1e9 + 7;\n\n//finally calculating the contribution of each element\n  for (int i = 0; i < nums.size(); i++) {\n\t\tlong t = (preSum[right[i]] - preSum[left[i] + 1]) * nums[i];\n\t\tans = max(ans, t);\n  }\n\n  return ans % mod; \n    }\n```
['Stack', 'C', 'Prefix Sum']