Associated Course(s):
Must Do Interview Preparation
Sudo Placement 2019

Given an array **A** of **N** positive integers. Find the **sum** of **maximum sum increasing subsequence** of the given array.

**Input:**

The first line of input contains an integer **T** denoting the number of test cases. The first line of each test case is N(the size of array). The second line of each test case contains array elements.

**Output:**

For each test case print the required answer in new line.

**Constraints:**

1 ≤ T ≤ 100

1 ≤ N ≤ 10^{6}

1 ≤ A_{i} ≤ 10^{6}

**Example:**

**Input:**

2

7

1 101 2 3 100 4 5

4

10 5 4 3

**Output:**

106

10

**Explanation:**

**Testcase 1:** All the increasing subsequences are : (1,101); (1,2,3,100); (1,2,3,4,5). Out of these (**1, 2, 3, 100**) has maximum sum,i.e., 106.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

the_coder95 | 465 |

thanuvinu94 | 388 |

adityasuman2025 | 305 |

Senbonzakura_Kageyoshi | 297 |

PrakharBansal1 | 274 |

the_coder95 | 1691 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 1064 |

samay_kam_hai | 724 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.