SEGSUM2 related doubt

Can anyone help in finding the bug in my code.I have coded my solution as given in the editorial but not getting where it is going wrong.
https://www.codechef.com/viewplaintext/11379661
question link :SUBSEG2 Problem - CodeChef