
    Given a dataset of patient behavior indicators where negative values represent risk factors and positive values represent protective factors, develop a function that analyzes the n most recent indicators and reorganizes them to group all risk factors before protective factors while maintaining their chronological sequence within each category. This reorganization will help healthcare providers quickly identify the concentration of risk factors in a patient's recent history while preserving the temporal progression of both risky and protective behaviors.
    

    
def re_arrange_array(arr, n):
    """
    Given a dataset of patient behavior indicators where negative values represent risk factors and positive values represent protective factors, develop a function that analyzes the n most recent indicators and reorganizes them to group all risk factors before protective factors while maintaining their chronological sequence within each category. This reorganization will help healthcare providers quickly identify the concentration of risk factors in a patient's recent history while preserving the temporal progression of both risky and protective behaviors.
    

    """
def re_arrange_array(arr, n):
    """
    Given a dataset of patient behavior indicators where negative values represent risk factors and positive values represent protective factors, develop a function that analyzes the n most recent indicators and reorganizes them to group all risk factors before protective factors while maintaining their chronological sequence within each category. This reorganization will help healthcare providers quickly identify the concentration of risk factors in a patient's recent history while preserving the temporal progression of both risky and protective behaviors.
    

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