Simple O(n) solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int 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 minl = nums[0],minr = nums[n-1],ans = INT_MAX;\n        for(int i = 1;i<n;i++){\n            minl = min(minl,nums[i-1]);\n            l_r[i] = minl;\n        }\n        for(int i = n-2;i >= 0;i--){\n            minr = min(minr,nums[i+1]);\n            r_l[i] = minr;\n        }\n\n        for(int i = 1;i<n-1;i++){\n            if(nums[i] > l_r[i] && nums[i] > r_l[i]){\n                ans = min(ans,nums[i]+l_r[i]+r_l[i]);\n            }\n        }\n        return ans == INT_MAX ? -1 : ans;\n    }\n};\n```
['Array', 'C++']