Best Java Solution || Beats 100%
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```\nclass Solution {\n    public int minimumSum(int[] arr) {\n        int n = arr.length;\n        int min1[] = new int[n];\n        int min2[] = new int[n];\n\n        min1[0] = arr[0];\n        min2[n-1] = arr[n-1];\n\n        for(int i=1; i<n; i++){\n            min1[i] = Math.min(min1[i-1],arr[i]);\n        }\n\n        for(int i=n-2; i>=0; i--){\n            min2[i] = Math.min(min2[i+1],arr[i]);\n        }\n\n        int ans = Integer.MAX_VALUE;\n\n        for(int i=1; i<n-1; i++){\n            if(min1[i-1]<arr[i] && min2[i+1]<arr[i]){\n                ans = Math.min(ans,min1[i-1]+arr[i]+min2[i+1]);\n            }\n        }\n\n        if(ans==Integer.MAX_VALUE) return -1;\n        else return ans;\n    }\n}\n```
['Java']