题目描述
Problem Description
Dusa eats Yobis, but only those within a certain size range.
If Dusa encounters a Yobi smaller than itself, it will eat the Yobi and absorb its size (i.e., increase its own size by the Yobi's size).
For example, if Dusa's size is $10$ and it encounters a Yobi of size $6$, Dusa will eat the Yobi and its size will increase to $10 + 6 = 16$.
If Dusa encounters a Yobi that is the same size or larger, Dusa will choose to flee and not eat the Yobi.
Dusa now encounters a sequence of Yobis in order. It is guaranteed that Dusa will inevitably encounter a Yobi that causes it to flee. You need to determine the size of Dusa when it flees.
Input Format
The first line of input contains a positive integer $D$ representing Dusa's initial size.
Each subsequent line contains a positive integer representing the size of the encountered Yobi in order.
Output Format
Output a positive integer $R$ representing the size of Dusa when it flees.
Sample Input and Output
Sample Input #1
5
3
2
9
20
22
14
Sample Output #1
19
Sample Input #2
10
10
3
5
13
Sample Output #2
10
Notes
[Sample 1 Explanation]
Dusa can eat the Yobi of size $3$, increasing its size to $8$. Dusa can eat the Yobi of size $2$, increasing its size to $10$. Dusa can eat the Yobi of size $9$, increasing its size to $19$. The Yobi of size $20$ causes Dusa to flee.
[Sample 2 Explanation]
The Yobi of size $10$ causes Dusa to flee, and its size remains unchanged.
[Data Range]
For all data, the input numbers do not exceed $5 \times 10^5$, and the total number of input lines does not exceed $2 \times 10^5$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分