
    Given a delivery route segment with traffic delay times recorded at n checkpoints, and knowing this route segment must be repeated k times throughout the day for multiple delivery cycles, determine the longest continuous period of delays that could impact delivery schedules. The delay times at each checkpoint follow the same pattern for each cycle, and the goal is to identify the maximum cumulative delay time that could occur across consecutive checkpoints, potentially spanning across multiple cycles of the route.
    

    
def max_sub_array_sum_repeated(a, n, k):
    """
    Given a delivery route segment with traffic delay times recorded at n checkpoints, and knowing this route segment must be repeated k times throughout the day for multiple delivery cycles, determine the longest continuous period of delays that could impact delivery schedules. The delay times at each checkpoint follow the same pattern for each cycle, and the goal is to identify the maximum cumulative delay time that could occur across consecutive checkpoints, potentially spanning across multiple cycles of the route.
    

    """
def max_sub_array_sum_repeated(a, n, k):
    """
    Given a delivery route segment with traffic delay times recorded at n checkpoints, and knowing this route segment must be repeated k times throughout the day for multiple delivery cycles, determine the longest continuous period of delays that could impact delivery schedules. The delay times at each checkpoint follow the same pattern for each cycle, and the goal is to identify the maximum cumulative delay time that could occur across consecutive checkpoints, potentially spanning across multiple cycles of the route.
    

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