Mr.Hsiung dresses fashionably every day. Not surprisingly, he only does this because he is overly conscious about his height. He has a sequence of
integers, each representing his height at a certain time. However, he organized them poorly. Mr.Hsiung doesn't care about having all of the heights, so he will take some of them, while keeping their relative order. Additionally, this new subsequence of numbers he has must be strictly increasing, as it wouldn't make sense for him to grow shorter. He also wants the sequence with the sum of its elements being maximal. Help Mr.Hsiung find this sum.
Input Specification
The first line will contain the integer
, the number of elements in the original sequence. The
lines will contain
elements, a positive integer at most
.
For
of test cases,
.
Output Specification
Output the maximum sum of Mr.Hsiung's new sequence.
Sample Input 1
Copy
5
4
1
2
5
6
Sample Output 1
Copy
15
Explanation 1
In this case, the subsequence
is optimal.
Sample Input 2
Copy
5
10
9
8
7
6
Sample Output 2
Copy
10
Explanation 2
In this case, no subsequence containing more than
element is increasing. Thus, choosing
is optimal.
Comments
Its possible for a person to stay the same height too....