Test case are not passed

This is the link to my code:-

which is running fine on other ide and giving correct output but it’s failing all the test cases on the portal. Please check the code and highlight the mistake done by me…

@Jitinkansal
take into consideration the long constraints which are failing your code

what should be the answer for this testcase
15
4 8 8 9 2 4 7 6 1 5 9 6 11 1 2
my answer is 24.

@Jitinkansal your answer is correct

then what’s the issue with my code can you please tell…

@Jitinkansal use long long int everywhere

yaa it did work.
Is it because the area of bigger value can go large than the Integer capacity.
I didn’t think about this.

Thank you for your help.

@Jitinkansal
no problem. Please mark your doubt as resolved and rate as well :slight_smile: