Python solution with Explanation using 2 variables O(n) time, O(1) space
ignored variable stores the contiguous cursum by ignoring any one element\nnotignored stores the contiguous sum by not ignoring any value so far\n\ncase 1)\nWhe
ignored variable stores the contiguous cursum by ignoring any one element\nnotignored stores the contiguous sum by not ignoring any value so far\n\ncase 1)\nWhenever we have a positive value, we simply add the value to the ingored sum and notignored sum\n\ncase 2) \nIf we encounter a negative value, the notignored sum is still obtained by adding negative value to it.\nThe ignored sum can be two things.\n    1) We choose to ignore the current value, in which case, the ignored sum = notignored sum from before\n    2) We choose to include the current value, in which case, we choose the previous ignored sum and add cur value to it.\nWhich of these two options, to do, is simply the max of both options.\n\ncase 3) \nAt the end of case 2) , if either ignored sum or notignored sum becomes negative, we can reset them to 0.\n\n\n```\ndef maximumSum(self, a: List[int]) -> int:\n        ignored, notignored, res = 0, 0, a[0]\n        for num in a:\n            if num >= 0:\n                ignored += num\n\t\t\t\tnotignored += num\n            else:\n                ignored = max(ignored + num, notignored)\n                notignored += num\n                \n            res = max([res, ignored if ignored != 0 else -math.inf, notignored if notignored != 0 else -math.inf])\n            if ignored < 0: ignored = 0\n            if notignored < 0: notignored = 0\n        return max(res, max(a))    \n```
[]