
    Design a fraud detection algorithm that identifies the highest total value of consecutive transactions within a user's spending pattern that repeats across k monitoring cycles. The algorithm should analyze a sequence of n transactions and determine the maximum sum of adjacent transaction amounts when this sequence is analyzed over k repeated monitoring periods to detect potential recurring fraud patterns.
    

    
def max_sub_array_sum_repeated(a, n, k):
    """
    Design a fraud detection algorithm that identifies the highest total value of consecutive transactions within a user's spending pattern that repeats across k monitoring cycles. The algorithm should analyze a sequence of n transactions and determine the maximum sum of adjacent transaction amounts when this sequence is analyzed over k repeated monitoring periods to detect potential recurring fraud patterns.
    

    """
def max_sub_array_sum_repeated(a, n, k):
    """
    Design a fraud detection algorithm that identifies the highest total value of consecutive transactions within a user's spending pattern that repeats across k monitoring cycles. The algorithm should analyze a sequence of n transactions and determine the maximum sum of adjacent transaction amounts when this sequence is analyzed over k repeated monitoring periods to detect potential recurring fraud patterns.
    

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