[Java] Simple and Easy understood
class Solution {\n\tlong MOD=1_000_000_007;\n\t   \n\n    public int maxSumMinProduct(int[] nums) {\n\t   long ret = 0;\n\t   \n\t   for (int i = 0; i < nums.le
class Solution {\n\tlong MOD=1_000_000_007;\n\t   \n\n    public int maxSumMinProduct(int[] nums) {\n\t   long ret = 0;\n\t   \n\t   for (int i = 0; i < nums.length; i++) {\n\t\t   \n\t\t   if (i == 0 || nums[i] !=nums[i-1]) {\n\t\t\t   long temp = getSum(nums, i);\n\t\t\t   \n\t\t\t   long t2 = (temp * nums[i]);\n\t\t\t   if (t2 > ret) {\n\t\t\t\t   ret = t2;\n\t\t\t   }\t\t\t   \n\t\t   }\n\n\t   }\n        ret = ret%MOD;\n\t   return (int)ret;\n        \n    }\n   \n   \tlong getSum(int[] nums, int cur) {\n   \t\tlong ret = nums[cur];\n   \t\t\n   \t\tlong left = 0;\n   \t\tint val = nums[cur];\n   \t\t\n   \t\tfor (int i = cur-1; i>= 0 && nums[i]>=val;i--) {\n   \t\t\tleft += nums[i];\n   \t\t}\n   \t\t\n        \n   \t\tret += left;\n        ret = ret;\n   \t\t\n   \t\tlong right = 0;\n   \t\tfor (int i = cur+1; i < nums.length && nums[i]>=val; i++)  {\n            right += nums[i];\n        }\n   \t\t\t\n   \t\t\n   \t\tret += right;\n   \t\treturn ret;\n   \t}\n}
[]