
    Design a fraud detection algorithm that identifies the highest-risk spending pattern by finding the maximum sum of chronologically increasing transaction amounts up to a specific point in a customer's transaction history, while also considering a future transaction of interest. The algorithm should analyze the transaction sequence up to a given checkpoint in the history and include a specific future transaction that occurs after this checkpoint. The goal is to determine if the future transaction follows the pattern of increasing purchase amounts that could indicate potential card theft or unauthorized use. The solution should help identify cases where spending gradually increases over time before a suspicious large transaction occurs.
    

    
def max_sum_increasing_subseq(a, n, index, k):
    """
    Design a fraud detection algorithm that identifies the highest-risk spending pattern by finding the maximum sum of chronologically increasing transaction amounts up to a specific point in a customer's transaction history, while also considering a future transaction of interest. The algorithm should analyze the transaction sequence up to a given checkpoint in the history and include a specific future transaction that occurs after this checkpoint. The goal is to determine if the future transaction follows the pattern of increasing purchase amounts that could indicate potential card theft or unauthorized use. The solution should help identify cases where spending gradually increases over time before a suspicious large transaction occurs.
    

    """
def max_sum_increasing_subseq(a, n, index, k):
    """
    Design a fraud detection algorithm that identifies the highest-risk spending pattern by finding the maximum sum of chronologically increasing transaction amounts up to a specific point in a customer's transaction history, while also considering a future transaction of interest. The algorithm should analyze the transaction sequence up to a given checkpoint in the history and include a specific future transaction that occurs after this checkpoint. The goal is to determine if the future transaction follows the pattern of increasing purchase amounts that could indicate potential card theft or unauthorized use. The solution should help identify cases where spending gradually increases over time before a suspicious large transaction occurs.
    

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