
    Given a sequence of credit card transactions over a monitoring window, analyze k consecutive windows of the same transaction pattern to identify the highest total spend amount from any continuous sequence of purchases that could indicate potential fraud. The transactions from the initial monitoring window repeat k times in sequence, and your task is to find the maximum sum of any contiguous sequence of transactions across these repeated windows.
    

    
def max_sub_array_sum_repeated(a, n, k):
    """
    Given a sequence of credit card transactions over a monitoring window, analyze k consecutive windows of the same transaction pattern to identify the highest total spend amount from any continuous sequence of purchases that could indicate potential fraud. The transactions from the initial monitoring window repeat k times in sequence, and your task is to find the maximum sum of any contiguous sequence of transactions across these repeated windows.
    

    """
def max_sub_array_sum_repeated(a, n, k):
    """
    Given a sequence of credit card transactions over a monitoring window, analyze k consecutive windows of the same transaction pattern to identify the highest total spend amount from any continuous sequence of purchases that could indicate potential fraud. The transactions from the initial monitoring window repeat k times in sequence, and your task is to find the maximum sum of any contiguous sequence of transactions across these repeated windows.
    

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