Easiest way to solve
\n\n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(n)\n# Code\n\nclass Solution {\n    public int maximumSum(int[] arr) {\n        int n = arr.l
\n\n# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(n)\n# Code\n```\nclass Solution {\n    public int maximumSum(int[] arr) {\n        int n = arr.length;\n        int[] forward = new int[n];\n        int currentSum = arr[0];\n        forward[0] = currentSum;\n        int maxSum = currentSum;\n\n        for (int i = 1; i < n; i++) {\n            currentSum = Math.max(arr[i], currentSum + arr[i]);\n            forward[i] = currentSum;\n            maxSum = Math.max(maxSum, currentSum);\n        }\n        int[] backward = new int[n];\n        currentSum = arr[n - 1];\n        backward[n - 1] = currentSum;\n\n        for (int i = n - 2; i >= 0; i--) {\n            currentSum = Math.max(arr[i], currentSum + arr[i]);\n            backward[i] = currentSum;\n        }\n\n        for (int i = 1; i < n - 1; i++) {\n            maxSum = Math.max(maxSum, forward[i - 1] + backward[i + 1]);\n        }\n\n        return maxSum;\n    }\n}\n\n```
['Java']