
    Given a sequence of maintenance cost readings from a transit vehicle's sensors over time, determine the highest cumulative maintenance expense pattern that follows an increasing trend up to a current checkpoint and must include a specific future maintenance event. The maintenance costs must be selected in a way that each chosen cost is greater than the previous one, forming an upward trend in expenses. The analysis should consider all readings from the start until the current checkpoint, plus exactly one mandatory future maintenance event that occurs after the current checkpoint. The goal is to help transit authorities identify the most resource-intensive maintenance sequence that follows this pattern for better budget planning.
    

    
def max_sum_increasing_subseq(a, n, index, k):
    """
    Given a sequence of maintenance cost readings from a transit vehicle's sensors over time, determine the highest cumulative maintenance expense pattern that follows an increasing trend up to a current checkpoint and must include a specific future maintenance event. The maintenance costs must be selected in a way that each chosen cost is greater than the previous one, forming an upward trend in expenses. The analysis should consider all readings from the start until the current checkpoint, plus exactly one mandatory future maintenance event that occurs after the current checkpoint. The goal is to help transit authorities identify the most resource-intensive maintenance sequence that follows this pattern for better budget planning.
    

    """
def max_sum_increasing_subseq(a, n, index, k):
    """
    Given a sequence of maintenance cost readings from a transit vehicle's sensors over time, determine the highest cumulative maintenance expense pattern that follows an increasing trend up to a current checkpoint and must include a specific future maintenance event. The maintenance costs must be selected in a way that each chosen cost is greater than the previous one, forming an upward trend in expenses. The analysis should consider all readings from the start until the current checkpoint, plus exactly one mandatory future maintenance event that occurs after the current checkpoint. The goal is to help transit authorities identify the most resource-intensive maintenance sequence that follows this pattern for better budget planning.
    

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