Test case 0 and 5 are failing

Test case 0 and 5 are failing though i’m not able to figure out what the problem is. please help

for test case like
4
6
99999 8999565 809950 1234999
123456 777777
the correct answer is
8999565 not 8999566
array is not sorted
here is your corrrected code: