fixed error by resetting sum_left to zero each loop. The code now works
for the sample input.