
    Given a delivery route with traffic congestion scores for each road segment and knowing this route pattern repeats k times throughout different shifts of the day, find the continuous sequence of road segments across all shifts that would result in the highest cumulative traffic congestion impact on delivery times. The route pattern contains n segments, and each segment has a traffic density score that indicates the level of congestion on that particular road section.
    

    
def max_sub_array_sum_repeated(a, n, k):
    """
    Given a delivery route with traffic congestion scores for each road segment and knowing this route pattern repeats k times throughout different shifts of the day, find the continuous sequence of road segments across all shifts that would result in the highest cumulative traffic congestion impact on delivery times. The route pattern contains n segments, and each segment has a traffic density score that indicates the level of congestion on that particular road section.
    

    """
def max_sub_array_sum_repeated(a, n, k):
    """
    Given a delivery route with traffic congestion scores for each road segment and knowing this route pattern repeats k times throughout different shifts of the day, find the continuous sequence of road segments across all shifts that would result in the highest cumulative traffic congestion impact on delivery times. The route pattern contains n segments, and each segment has a traffic density score that indicates the level of congestion on that particular road section.
    

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