implemented Kadane's algorithm for maximum sub-array