Modified Kadane from Ubuntu