What is the error in this code

I didn’t get ur code. But what i have done in this question is that:

  1. First calculate the maximum subarray sum using kadane’s algorithm.
  2. Now make all elements of the array of opposite sign.(if positive then make it negative,if negative then make it positive)
  3. Now again use kadane algo to find max subarray sum.
  4. Subtract the result came from above by total sum.
  5. ans is the maximum of ans in step 4 and step 1.

what do you want to explain in the 4 point

subtract the total sum with kadane sum in step 3