Easiest c++ solution 0ms beats 100% solve by suffix array
IntuitionApproachComplexity
Time complexity: O(n)

Space complexity: O(n)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: $$O(n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(n)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int minimumSum(vector<int>& nums) {
        int ans = INT_MAX;
        vector<int> suffix(nums.size(), nums.back());
        for(int i = nums.size() - 2;i >= 0;i--){
            suffix[i] = min(suffix[i + 1], nums[i]);
        }

        int mn = nums[0];
        for(int i = 1;i < nums.size() - 1;i++){
            if(nums[i] <= mn) mn = nums[i];
            else{
                if(nums[i] > suffix[i + 1]) ans = min(ans, mn + nums[i] + suffix[i + 1]);
            }
        }

        return (ans == INT_MAX)? -1 : ans;
    }
};
```
['Array', 'Suffix Array', 'C++']