CHARGES solution giving WA result

why is the following code giving WA (ques: CHARGES from May Lunchtime 2021)

LINK to Solution: CodeChef: Practical coding for everyone

Check out this testcase :slightly_smiling_face:

1
1 3
0
1 1 1

1 Like

Hi ,
You have ignored if number of charges is 1.
If it is 1 then answer will always be zero

1 Like