Java maxPrefix + maxSurfix
\n    public int maximumSum(int[] arr) {\n        int n = arr.length, tail[] = new int[n], head[] = new int[n], res = Integer.MIN_VALUE;\n        for (int i = 0
```\n    public int maximumSum(int[] arr) {\n        int n = arr.length, tail[] = new int[n], head[] = new int[n], res = Integer.MIN_VALUE;\n        for (int i = 0; i < n; i++) {\n            tail[i] = i == 0 ? arr[i] : Math.max(arr[i], tail[i - 1] + arr[i]);\n            head[n - 1 - i] = i == 0 ? arr[n - 1 - i] : Math.max(arr[n - 1 - i], head[n - i] + arr[n - 1 - i]);\n            res = Math.max(res, Math.max(tail[i], head[n - 1 - i]));\n        }\n        for (int i = 1; i < n - 1; i++) {\n            res = Math.max(res, tail[i - 1] + head[i + 1]);\n        }\n        return res;\n    }\n```
[]