For input 1 , 2, 3 ,4 it is giving 9 as ans
Hey do this
if(i>=1)
current_sum = cum_sum[j] + cum_sum[i-1];
else
current_sum= cum_sum[j] ;
i dont understand it where are you telling to insert it and how will it make any difference kindly edit the code and comment out mistake it would be easier to understand.
i have checked current sum array it was completely correct
Hey Sorry but I wont be able to edit your code right now
You have to use this instead of line 20 because when j=i and i=0 then you are trying to subtract cursum[-1] which will give you garbage value.
If tour doubt is resolved then please mark it so 
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.