human
Maximum subarray sum in an array created after repeated concatenation | Returns sum of maximum sum subarray created after concatenating a [ 0. . n - 1 ] k times ..
This is where it differs from Kadane 's  algorithm. We use  modular arithmetic to  find next element..
Driver program to test maxSubArraySum"
How can the above be solved in Python?
assistant
#Here is code to maximum subarray sum in an array created after repeated concatenation and the other steps required.
 def maxSubArraySumRepeated ( a , n , k ) :
	max_so_far = - 2147483648
	max_ending_here = 0
	for i in range ( n * k ) :
		max_ending_here = max_ending_here + a [ i % n ]
		if ( max_so_far < max_ending_here ) :
			max_so_far = max_ending_here
		if ( max_ending_here < 0 ) :
			max_ending_here = 0
	return max_so_far
a = [ 10 , 20 , - 30 , - 1 ]
n = len ( a )
k = 3
print ( " Maximum ▁ contiguous ▁ sum ▁ is ▁ " , maxSubArraySumRepeated ( a , n , k ) )