
    In a social networking platform, develop an algorithm that analyzes a list of connection scores between users to find the strongest possible friend recommendation chain, where the relationship strength initially grows stronger through common interests and mutual friends, then naturally declines due to diverging interests. The connection scores between consecutive users in the chain must first increase then decrease, and your algorithm should return the maximum sum of these connection scores.
    

    
def max_sum(arr):
    """
    In a social networking platform, develop an algorithm that analyzes a list of connection scores between users to find the strongest possible friend recommendation chain, where the relationship strength initially grows stronger through common interests and mutual friends, then naturally declines due to diverging interests. The connection scores between consecutive users in the chain must first increase then decrease, and your algorithm should return the maximum sum of these connection scores.
    

    """
def max_sum(arr):
    """
    In a social networking platform, develop an algorithm that analyzes a list of connection scores between users to find the strongest possible friend recommendation chain, where the relationship strength initially grows stronger through common interests and mutual friends, then naturally declines due to diverging interests. The connection scores between consecutive users in the chain must first increase then decrease, and your algorithm should return the maximum sum of these connection scores.
    

    """
    MSIBS = arr[:]
    for i in range(len(arr)):
        for j in range(0, i):
            if arr[i] > arr[j] and MSIBS[i] < MSIBS[j] + arr[i]:
                MSIBS[i] = MSIBS[j] + arr[i]
    MSDBS = arr[:]
    for i in range(1, len(arr) + 1):
        for j in range(1, i):
            if arr[-i] > arr[-j] and MSDBS[-i] < MSDBS[-j] + arr[-i]:
                MSDBS[-i] = MSDBS[-j] + arr[-i]
    max_sum = float('-Inf')
    for (i, j, k) in zip(MSIBS, MSDBS, arr):
        max_sum = max(max_sum, i + j - k)
    return max_sum