
    At a busy intersection, develop a traffic signal optimization system that analyzes the most recent n vehicle time gaps and reorganizes them to separate congested patterns (negative time gaps) from smooth-flowing patterns (positive time gaps), while maintaining their sequential order within each category. This reorganization helps traffic engineers quickly identify periods of congestion versus normal flow within the analyzed time window to adjust signal timing accordingly.
    

    
def re_arrange_array(arr, n):
    """
    At a busy intersection, develop a traffic signal optimization system that analyzes the most recent n vehicle time gaps and reorganizes them to separate congested patterns (negative time gaps) from smooth-flowing patterns (positive time gaps), while maintaining their sequential order within each category. This reorganization helps traffic engineers quickly identify periods of congestion versus normal flow within the analyzed time window to adjust signal timing accordingly.
    

    """
def re_arrange_array(arr, n):
    """
    At a busy intersection, develop a traffic signal optimization system that analyzes the most recent n vehicle time gaps and reorganizes them to separate congested patterns (negative time gaps) from smooth-flowing patterns (positive time gaps), while maintaining their sequential order within each category. This reorganization helps traffic engineers quickly identify periods of congestion versus normal flow within the analyzed time window to adjust signal timing accordingly.
    

    """
    j = 0
    for i in range(0, n):
        if arr[i] < 0:
            temp = arr[i]
            arr[i] = arr[j]
            arr[j] = temp
            j = j + 1
    return arr