SIMPLE C++ SOLUTION || O(n)
Code\n\nint minimumSum(vector<int>& nums) {\n    int n=nums.size();\n    vector<int> l_r(n,INT_MAX);\n    vector<int> r_l(n,INT_MAX);\n    int minil=nums[0],min
# Code\n```\nint minimumSum(vector<int>& nums) {\n    int n=nums.size();\n    vector<int> l_r(n,INT_MAX);\n    vector<int> r_l(n,INT_MAX);\n    int minil=nums[0],minir=nums[n-1],ans=INT_MAX;\n    for(int i=1;i<n;i++){\n        minil=min(minil,nums[i-1]);\n        l_r[i]=minil;\n    }\n    for(int i=n-2;i>=0;i--){\n        minir=min(minir,nums[i+1]);\n        r_l[i]=minir;\n    }\n    for(int i=1;i<n-1;i++){\n        if(l_r[i]<nums[i] && r_l[i]<nums[i]){\n            ans=min(ans,nums[i]+l_r[i]+r_l[i]);\n        }\n    }\n    return (ans==INT_MAX)?-1:ans;        \n}\n```
['Array', 'Suffix Array', 'Prefix Sum', 'C++']