Wrong answer all most test cases

Even thought the compiler is giving correct results, the test cases are failing. Could you please point out the error in my code. Also, TA said that correct answer for the test case 8
1 34 3 98 9 76 45 4
should be 998764453341. My code gives 998764543431, isn’t that bigger?

yes see this