Jianguo Trump
题号:NC207415
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Jianguo Trump performs tasks in country A, he has performed n(0<n<1000) tasks in one year, and the value of the i-th task is vi(0<vi<1e5), the more value of the task is, the more contribute to C country. Now he wants to report some of these tasks to country C, but he wants to show that he has made progress every time, so each task he reports will bring more economic growth than the last task, i.e. vi>vj, i > j. What is the maximum total value of the tasks he reports?

输入描述:

The input contains multiple test cases. Each test case includes 2 lines.
The first line is a positive integer n, the second line include n positive integers ai.

输出描述:

For each case, print the result in one line.
示例1

输入

复制
4
6 2 4 8

输出

复制
14

说明

Jianguo Trump can report 6, 8 to get the max value 14
示例2

输入

复制
9
7 7 3 7 8 1 7 4 1

输出

复制
18

说明

Jianguo Trump can report 3, 7, 8 to get the max value 18