Simple Solution in Java || O(N)
Java []\nclass Solution {\n    public int minimumSum(int[] nums) {\n        int n=nums.length, pre[]=new int[n], suf[]=new int[n], prevp=Integer.MAX_VALUE, prev
```Java []\nclass Solution {\n    public int minimumSum(int[] nums) {\n        int n=nums.length, pre[]=new int[n], suf[]=new int[n], prevp=Integer.MAX_VALUE, prevs=Integer.MAX_VALUE, res=Integer.MAX_VALUE;\n        for(int i=0;i<n;i++) {\n            prevp=pre[i]=Math.min(nums[i], prevp);\n            prevs=suf[n-i-1]=Math.min(nums[n-i-1], prevs);\n        }\n        for(int i=1;i<n-1;i++) {\n            if(pre[i-1]<nums[i] && nums[i]>suf[i+1])\n                res=Math.min(res, nums[i]+pre[i-1]+suf[i+1]);\n        }\n        return res==Integer.MAX_VALUE? -1: res;\n    }\n}\n```
['Java']