#d2289. 最大和上升子序列
最大和上升子序列
Maximum Sum Increasing Subsequence
Problem Description
Given an array of length , find the increasing subsequence with the largest sum. That is, find indices satisfying and , such that is maximized.
Input Format
The first line contains an integer .
The next line contains integers .
Output Format
One number: the answer.
Sample Input
6
3 7 4 2 6 8
Sample Output
21
Constraints
For all data, .