By Kay Akashi
You're playing a game that is composed of rounds. Before starting a game, you have coin. In -th round, you earn coins. However, the maximum number of coins you can have is and minimum is ( you will not have more than coins, and you will not have less than coin). What is the resulting number of coins you have after finishing all rounds?
Note that, can be negative: in this case, you lose coins rather than earning them.
, .
The first line of input contains one integer, . The second line of input contains integers, .
Output the answer.
4
3 5 5 -3
7
The numbers of coins you have after finishing each round are as follows: , , , and , hence the answer is .
3
2 -4 -4
0
The numbers of coins you have after finishing each round are as follows: , , and hence the answer is .