Maximum circular array sum

my code is giving correct answer to the sample input in the question and various other inputs
so why does it show wrong answer in all test cases
and which test cases are failing?

2
8
10 -3 -4 7 6 5 -4 -1
8
-1 40 -14 7 6 5 -4 -1

for this input output should be
23
52

but your output is
21
44

try again

HInt: Kadane’s algorithm for circular array

Case 1: The elements that contribute to the maximum sum are arranged such that no wrapping is there. Examples: {-10, 2, -1, 5}, {-2, 4, -1, 4, -1}. In this case without wraping result will produce .

Case 2: The elements which contribute to the maximum sum are arranged such that wrapping is there. Examples: {10, -12, 11}, {12, -5, 4, -8, 11}.
find out the sum of non contributing elements and subtract this sum from the total sum. To find out the sum of non contributing, invert sign of each element and then run Kadane’s algorithm.

Finally we compare the sum obtained by both cases, and return the maximum of the two sums