Kadane sub array algorithm