Algorithm is not working

This algorithm is not working for arr = [-500]. It should return -500 but its returning 0.

yes there needs to be little updte in the code
please share ur code
i`ll make the updates and share it with u