407628: GYM102861 G Game Show!

Memory Limit:1024 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Game Show!time limit per test0.25 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

The Society of Bright Competitors (SBC) organizes television shows to its members (and currently it also broadcasts online!). SBC uses a a system of credits called sbecs, which can be used by players to participate in competitions or can be exchanged for prizes at the end of each season. SBC started a new type of game, and needs to do some simulations to avoid very large losses in the prize pool!

Ricardo is going to try the new game. He must bet $$$100$$$ sbecs, which are transferred to his game balance. Then, a sequence of boxes is positioned. The game consists of rounds, and the maximum number of rounds is equal to the number of boxes. At each round, Ricardo decides whether to open the next box or to quit the game. If Ricardo quits, he gets the current balance of sbecs back. If Ricardo opens the next box, its content, which is a secret number, is added to his balance and the game continues. As the secret number in the box may be negative, Ricardo may end up at a loss! The game ends when Ricardo decides to quit or when the last box is opened.

SBC hired you to test the game. From the content of the boxes, you must decide what would be the largest possible balance that Ricardo could get.

Input

The first input line contains an integer $$$C$$$, $$$1 \le C \le 100$$$, which is the number of boxes in the game. After the first input line, there are $$$C$$$ more lines. Each of the $$$C$$$ lines contains the secret number of a box. The lines are in the same order of the boxes. The secret numbers are integers, $$$V$$$ , $$$−1000 \le V \le 1000$$$.

Output

Output a line containing an integer which is the largest possible balance that Ricardo may get, given that sequence of boxes.

ExamplesInput
4
-1
-2
-3
-4
Output
100
Input
5
-10
20
-30
40
-50
Output
120

加入题单

上一题 下一题 算法标签: