Kadane's algorithm.