Java AC O(n) time and O(1) space dp solution
dp represents current max sum including arr[i] -- either dp + arr[i] or arr[i] (if arr[i] > dp + arr[i], meaning dp is negative, we just drop dp and start over 
dp represents current max sum including arr[i] -- either dp + arr[i] or arr[i] (if arr[i] > dp + arr[i], meaning dp is negative, we just drop dp and start over from arr[i] as there is no point to keep a negative sum)\ndpExclude represents current max sum excluding arr[i]\ndpExclude can be itself + arr[i] since it already excluded one element previously. Or, it can be previous dp, meaning we exclude current element -- arr[i].\nWhen dpExclude is Integer.MIN_VALUE (has not been initialized), we can either exclude arr[0] (take only arr[1]) or exclude current element arr[1] (take previous value, which is dp or arr[0] as dp was initialized with arr[0]) \n```\n    public int maximumSum(int[] arr) {\n        int res = arr[0];\n        int dp = arr[0];\n        int dpExclude = Integer.MIN_VALUE;\n        for (int i = 1; i < arr.length; i++) {\n            dpExclude = dpExclude == Integer.MIN_VALUE ? Math.max(dp, arr[i]) : Math.max(dp, dpExclude + arr[i]);\n            dp = Math.max(dp + arr[i], arr[i]);\n            res = Math.max(dp, res);\n            res = Math.max(res, dpExclude);\n        }\n\n        return res;\n    }\n```
[]