
    Design a fraud detection algorithm that analyzes a user's historical transaction sequence to identify the highest-value legitimate spending pattern leading up to a checkpoint transaction, while also considering a specific future suspicious transaction. The algorithm should find the maximum total value of an increasing sequence of transactions from the start of the history up to the checkpoint, but must include the suspicious transaction that occurs after the checkpoint. The increasing pattern requirement ensures that the spending progression follows natural consumer behavior where transaction values typically escalate gradually rather than erratically. The solution should help determine if the suspicious transaction is anomalous compared to the user's established spending patterns.
    

    
def max_sum_increasing_subseq(a, n, index, k):
    """
    Design a fraud detection algorithm that analyzes a user's historical transaction sequence to identify the highest-value legitimate spending pattern leading up to a checkpoint transaction, while also considering a specific future suspicious transaction. The algorithm should find the maximum total value of an increasing sequence of transactions from the start of the history up to the checkpoint, but must include the suspicious transaction that occurs after the checkpoint. The increasing pattern requirement ensures that the spending progression follows natural consumer behavior where transaction values typically escalate gradually rather than erratically. The solution should help determine if the suspicious transaction is anomalous compared to the user's established spending patterns.
    

    """
def max_sum_increasing_subseq(a, n, index, k):
    """
    Design a fraud detection algorithm that analyzes a user's historical transaction sequence to identify the highest-value legitimate spending pattern leading up to a checkpoint transaction, while also considering a specific future suspicious transaction. The algorithm should find the maximum total value of an increasing sequence of transactions from the start of the history up to the checkpoint, but must include the suspicious transaction that occurs after the checkpoint. The increasing pattern requirement ensures that the spending progression follows natural consumer behavior where transaction values typically escalate gradually rather than erratically. The solution should help determine if the suspicious transaction is anomalous compared to the user's established spending patterns.
    

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