
    Design a function for the event recommendation system that processes a user's n most recent activity scores and reorganizes them to group all disliked activities (negative scores) before liked activities (positive scores), while maintaining the chronological order within each group to preserve user preference history. The function should only consider the first n activity scores from the user's interaction history while keeping the remaining scores unchanged.
    

    
def re_arrange_array(arr, n):
    """
    Design a function for the event recommendation system that processes a user's n most recent activity scores and reorganizes them to group all disliked activities (negative scores) before liked activities (positive scores), while maintaining the chronological order within each group to preserve user preference history. The function should only consider the first n activity scores from the user's interaction history while keeping the remaining scores unchanged.
    

    """
def re_arrange_array(arr, n):
    """
    Design a function for the event recommendation system that processes a user's n most recent activity scores and reorganizes them to group all disliked activities (negative scores) before liked activities (positive scores), while maintaining the chronological order within each group to preserve user preference history. The function should only consider the first n activity scores from the user's interaction history while keeping the remaining scores 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