#D3176. LISum
LISum
LISum
problem
Given the sequence of length . Find the maximum value of , where is one of the longest increasing subsequences of the sequence .
The longest increasing subsequence of the sequence is the longest subsequence that satisfies with all .
output
Output the maximum value of , where is one of the longest increasing subsequences of the sequence . Also, output a line break at the end.
Example
Input
4 6 4 7 8
Output
21
inputFormat
outputFormat
output
Output the maximum value of , where is one of the longest increasing subsequences of the sequence . Also, output a line break at the end.
Example
Input
4 6 4 7 8
Output
21
样例
4
6 4 7 8
21