Why it id not covering 1 testcase

Your code is not producing correct result for following test case :
4
-20
-10
-30
-50
Your output :
-50
-20
-30
-10
Expected output :
-50
-30
-20
-10