Sample test case running other are failing

hey @samadsid7, this code is from geeks for geeks and they have not consider the case when array elements are negative. But here some cases has negative values also. You code is still not working for testcases where numbers are posiitive, so I am modifying your code for this.

The above code will run perfectly when testcases have Positive value.

For negative values try to make changes.
I am giving you sample testcase for this

5 10
-1 33 -1 176 -1 46 -1 120 -1 300

Correct Answer:112