
    Design a medication safety system that analyzes the first n priority drugs from a list of medication interaction scores and reorganizes them so that all harmful interactions (negative scores) are flagged and grouped before beneficial interactions (positive scores), while maintaining the original sequence within each group to preserve the specific drug-to-drug interaction patterns. The system must process a list of interaction scores where negative values indicate dangerous combinations requiring immediate attention, and positive values represent safe or complementary drug interactions.
    

    
def re_arrange_array(arr, n):
    """
    Design a medication safety system that analyzes the first n priority drugs from a list of medication interaction scores and reorganizes them so that all harmful interactions (negative scores) are flagged and grouped before beneficial interactions (positive scores), while maintaining the original sequence within each group to preserve the specific drug-to-drug interaction patterns. The system must process a list of interaction scores where negative values indicate dangerous combinations requiring immediate attention, and positive values represent safe or complementary drug interactions.
    

    """
def re_arrange_array(arr, n):
    """
    Design a medication safety system that analyzes the first n priority drugs from a list of medication interaction scores and reorganizes them so that all harmful interactions (negative scores) are flagged and grouped before beneficial interactions (positive scores), while maintaining the original sequence within each group to preserve the specific drug-to-drug interaction patterns. The system must process a list of interaction scores where negative values indicate dangerous combinations requiring immediate attention, and positive values represent safe or complementary drug interactions.
    

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