
    Given historical daily patient admission data for a hospital department over n days, and assuming this admission pattern repeats k times in future cycles, find the highest consecutive sum of daily admissions across the extended forecast period to determine peak capacity requirements. The admission pattern is expected to repeat exactly k times, and the goal is to identify the maximum strain on resources during any continuous period within these cycles.
    

    
def max_sub_array_sum_repeated(a, n, k):
    """
    Given historical daily patient admission data for a hospital department over n days, and assuming this admission pattern repeats k times in future cycles, find the highest consecutive sum of daily admissions across the extended forecast period to determine peak capacity requirements. The admission pattern is expected to repeat exactly k times, and the goal is to identify the maximum strain on resources during any continuous period within these cycles.
    

    """
def max_sub_array_sum_repeated(a, n, k):
    """
    Given historical daily patient admission data for a hospital department over n days, and assuming this admission pattern repeats k times in future cycles, find the highest consecutive sum of daily admissions across the extended forecast period to determine peak capacity requirements. The admission pattern is expected to repeat exactly k times, and the goal is to identify the maximum strain on resources during any continuous period within these cycles.
    

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