
    Given a list of bus routes where each route's passenger demand is represented by a profitability indicator (negative for loss-making routes and positive for profitable routes), reorganize the first n priority routes so that all under-utilized routes are addressed before the high-demand routes, while maintaining the original sequence within each category. The optimization should only consider the specified n priority routes while leaving the remaining routes unchanged.
    

    
def re_arrange_array(arr, n):
    """
    Given a list of bus routes where each route's passenger demand is represented by a profitability indicator (negative for loss-making routes and positive for profitable routes), reorganize the first n priority routes so that all under-utilized routes are addressed before the high-demand routes, while maintaining the original sequence within each category. The optimization should only consider the specified n priority routes while leaving the remaining routes unchanged.
    

    """
def re_arrange_array(arr, n):
    """
    Given a list of bus routes where each route's passenger demand is represented by a profitability indicator (negative for loss-making routes and positive for profitable routes), reorganize the first n priority routes so that all under-utilized routes are addressed before the high-demand routes, while maintaining the original sequence within each category. The optimization should only consider the specified n priority routes while leaving the remaining routes unchanged.
    

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