Max sum subarray using kadane

this code will fail if all elements of array are negative