Https://ide.codingblocks.com/s/284427

one test case is failing dont know why. And also in the sample case
4
0
0 0 0 0
the output should be 10 but in question it is 15.

Yes that must be 10.
For that one case, is your code giving wrong answer or run error?
Also use all variables as long long because constraints are large enough.
For cases like
100000
0
all 100000 elements are zero
Result cannot be stored in int type

1 Like