
    Given a customer's historical monthly loan repayment pattern and its projected repetition over future periods, determine the highest consecutive sum of payments to evaluate their peak financial capacity for loan servicing. The repayment pattern of n months is expected to repeat k times in the future based on the customer's established behavior, and you need to find the maximum sum of continuous monthly payments across this extended timeline to assess their optimal repayment potential.
    

    
def max_sub_array_sum_repeated(a, n, k):
    """
    Given a customer's historical monthly loan repayment pattern and its projected repetition over future periods, determine the highest consecutive sum of payments to evaluate their peak financial capacity for loan servicing. The repayment pattern of n months is expected to repeat k times in the future based on the customer's established behavior, and you need to find the maximum sum of continuous monthly payments across this extended timeline to assess their optimal repayment potential.
    

    """
def max_sub_array_sum_repeated(a, n, k):
    """
    Given a customer's historical monthly loan repayment pattern and its projected repetition over future periods, determine the highest consecutive sum of payments to evaluate their peak financial capacity for loan servicing. The repayment pattern of n months is expected to repeat k times in the future based on the customer's established behavior, and you need to find the maximum sum of continuous monthly payments across this extended timeline to assess their optimal repayment potential.
    

    """
    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