
    Given a patient's historical readmission risk factors where negative values represent protective factors and positive values represent risk indicators, rearrange the most recent n risk factors so that all protective factors appear before risk indicators while maintaining their chronological order within each category. This reorganization will help clinicians quickly identify the balance of risk and protective factors in the patient's recent medical history while preserving the temporal sequence of each factor type.
    

    
def re_arrange_array(arr, n):
    """
    Given a patient's historical readmission risk factors where negative values represent protective factors and positive values represent risk indicators, rearrange the most recent n risk factors so that all protective factors appear before risk indicators while maintaining their chronological order within each category. This reorganization will help clinicians quickly identify the balance of risk and protective factors in the patient's recent medical history while preserving the temporal sequence of each factor type.
    

    """
def re_arrange_array(arr, n):
    """
    Given a patient's historical readmission risk factors where negative values represent protective factors and positive values represent risk indicators, rearrange the most recent n risk factors so that all protective factors appear before risk indicators while maintaining their chronological order within each category. This reorganization will help clinicians quickly identify the balance of risk and protective factors in the patient's recent medical history while preserving the temporal sequence of each factor type.
    

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