
    Design a loan approval algorithm that evaluates an applicant's creditworthiness by analyzing their credit score history. The algorithm should find the most favorable sequence of increasing credit scores up to a specific point in the applicant's credit history, while also considering a predicted future credit score. The sequence must demonstrate a consistent upward trend in creditworthiness and include both the historical scores up to the specified analysis point and the predicted future score. This evaluation method helps determine if the applicant shows a pattern of credit improvement that aligns with the bank's risk assessment criteria.
    

    
def max_sum_increasing_subseq(a, n, index, k):
    """
    Design a loan approval algorithm that evaluates an applicant's creditworthiness by analyzing their credit score history. The algorithm should find the most favorable sequence of increasing credit scores up to a specific point in the applicant's credit history, while also considering a predicted future credit score. The sequence must demonstrate a consistent upward trend in creditworthiness and include both the historical scores up to the specified analysis point and the predicted future score. This evaluation method helps determine if the applicant shows a pattern of credit improvement that aligns with the bank's risk assessment criteria.
    

    """
def max_sum_increasing_subseq(a, n, index, k):
    """
    Design a loan approval algorithm that evaluates an applicant's creditworthiness by analyzing their credit score history. The algorithm should find the most favorable sequence of increasing credit scores up to a specific point in the applicant's credit history, while also considering a predicted future credit score. The sequence must demonstrate a consistent upward trend in creditworthiness and include both the historical scores up to the specified analysis point and the predicted future score. This evaluation method helps determine if the applicant shows a pattern of credit improvement that aligns with the bank's risk assessment criteria.
    

    """
    dp = [[0 for i in range(n)] for i in range(n)]
    for i in range(n):
        if a[i] > a[0]:
            dp[0][i] = a[i] + a[0]
        else:
            dp[0][i] = a[i]
    for i in range(1, n):
        for j in range(n):
            if a[j] > a[i] and j > i:
                if dp[i - 1][i] + a[j] > dp[i - 1][j]:
                    dp[i][j] = dp[i - 1][i] + a[j]
                else:
                    dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = dp[i - 1][j]
    return dp[index][k]