Zeina just opened a restaurant, sadly due to COVID she might not be able to always profit from it.
After using statistics, she predicts the outcome of each day for the first N days.
Can you help Zeina calculate how much money she needs to lend from Rimawi (as you know treasures are into sketchy business) to make sure she ends up with a positive amount of profit each day.
First line is $n$ -- which is the number of days Zeina used statistics where $1 \le n \le 10^5$.
Second line contains $n$ integers $a_1, a_2, ..., a_n$ ($-10^4 \le a_i \le 10^4$) where the $a_i$ represents the expected profit for the $i^{th}$ day.
An integer representing her starting amount.
Input | Output |
---|---|
4 1 2 3 4 Copy
|
0 Copy
|
5 -1 0 2 -3 3 Copy
|
3 Copy
|