```python
def max_sum_increasing_subseq(a, n, index, k):
    prefix_len = index + 1
    
    if prefix_len <= 0:
        return a[k]

    # dp[i] will store the maximum sum of an increasing subsequence
    # of the prefix a[0...i] that ends with a[i].
    dp = [0] * prefix_len

    # Calculate dp values for the prefix a[0...index].
    for i in range(prefix_len):
        max_prev_sum = 0
        for j in range(i):
            if a[j] < a[i]:
                max_prev_sum = max(max_prev_sum, dp[j])
        
        dp[i] = a[i] + max_prev_sum

    # Find the maximum sum of a prefix subsequence that can be extended by a[k].
    # Such a subsequence must end with an element smaller than a[k].
    max_prefix_sum = 0
    for i in range(prefix_len):
        if a[i] < a[k]:
            max_prefix_sum = max(max_prefix_sum, dp[i])

    # The final result is a[k] plus the sum of the best valid prefix subsequence.
    return a[k] + max_prefix_sum
```