P10291 [CCC 2024 J2] Dusa And The Yobis
Description
Dusa eats Yobis, but only Yobis whose sizes fall within a certain range.
If Dusa encounters a Yobi that is smaller than it, it will eat the Yobi and absorb its size (that is, add the Yobi's size to its own 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 become $10 + 6 = 16$.
If Dusa encounters a Yobi that is the same size as it, or even larger, Dusa will run away and will not eat the Yobi.
Dusa now encounters a sequence of Yobis in order. It is guaranteed that Dusa will definitely encounter a Yobi that causes it to run away. You need to determine Dusa's size when it runs away.

Input Format
The first line contains a positive integer $D$, representing Dusa's initial size.
Each remaining line contains a positive integer, representing the sizes of the Yobis encountered in order.
Output Format
Output a positive integer $R$, representing Dusa's size when it runs away.
Explanation/Hint
**Sample 1 Explanation**
Dusa can eat the Yobi of size $3$ and its size becomes $8$. Dusa can eat the Yobi of size $2$ and its size becomes $10$. Dusa can eat the Yobi of size $9$ and its size becomes $19$. The Yobi of size $20$ causes Dusa to run away.
**Sample 2 Explanation**
The Yobi of size $10$ causes Dusa to run away, and its size does not change.
**Constraints**
For all testdata, it is guaranteed that every number in the input does not exceed $5 \times 10^5$, and the total number of input lines does not exceed $2 \times 10^5$.
Translated by ChatGPT 5