Kadane's algo(max subarray sum)

but what if all the elements in the array will be negative.

For kadane’s algo to work atleast one element need to be positive… So it wont work when all elements are negative…