C++ 2 solutions
Solution 1:\n\n/*\nAtmost one deletion is allowed\nAt a particular index the maximum sum can be obtained either by including the index and not deleting anything
Solution 1:\n```\n/*\nAtmost one deletion is allowed\nAt a particular index the maximum sum can be obtained either by including the index and not deleting anything before  or deleting the current or any of the previous indices\nThis translates to \ndp[i][0] = max(arr[i] , dp[i-1][0]+arr[i])\ndp[i][1] = max(dp[i-1][1]+arr[i] ,dp[i-1][0])\nAns is the maximum element in this nx2 dp array\n*/\nclass Solution {\npublic:\n    int maximumSum(vector<int>& arr) {\n        int ans = arr[0] , n =arr.size();\n        int dp[n][2];\n        dp[0][0] = arr[0];\n        dp[0][1] = -1e6;\n     \n        for(int i=1;i<n;i++){\n            dp[i][0] = max(arr[i] , dp[i-1][0]+arr[i]);\n            \n            dp[i][1] = max(dp[i-1][1]+arr[i] ,dp[i-1][0]);\n            \n            ans = max(ans , max(dp[i][0] , dp[i][1]));\n        }\n        return ans;\n    }\n};\n```\nSolution 2:\n```\nclass Solution {\npublic:\n    int maximumSum(vector<int>& arr) {\n        int n = arr.size();\n        vector<int> fwd(n) , bckd(n);\n        //apply kadane\'s algorithm in both the directions\n        //1. forward direction\n        fwd[0] = arr[0];\n        int gmax = arr[0] , lmax = arr[0];\n        for(int i=1;i<n;i++) {\n            lmax = max(arr[i],arr[i]+lmax);\n            gmax = max(gmax,lmax);\n            fwd[i] = lmax;\n        }\n        //2.backward direction\n        bckd[n-1] = arr[n-1];\n        gmax = arr[n-1] , lmax = arr[n-1];\n        for(int i=n-2;i>=0;i--) {\n            lmax = max(arr[i],lmax+arr[i]);\n            gmax = max(gmax,lmax);\n            bckd[i] = lmax;\n        }\n        int maxSum = gmax; \n       \n        for(int i=1;i<n-1;i++) {\n            maxSum = max(maxSum, max(0,bckd[i+1]) + max(0,fwd[i-1]));\n        }\n         if(maxSum<=0) //meaning there are no positive elements in arr\n            return *max_element(arr.begin(),arr.end());\n        return maxSum;\n    }\n};\n```
['Dynamic Programming', 'C', 'C++']