P6284 [COCI 2016/2017 #1] Tarifa

Description

To be able to surf the Internet, Pero bought a data plan: - Each month, he gets $x \rm{MB}$ of data. - Any unused data from a month can be carried over to the next month. Now we know how many $\rm{MB}$ of data Pero used in each of the first $n$ months of this plan. Please calculate how many $\rm{MB}$ of data he can use in month $n+1$.

Input Format

The first line contains an integer $x$. The second line contains an integer $n$. The next $n$ lines each contain an integer $p_i$, which indicates how many $\rm{MB}$ of data Pero used in month $i$.

Output Format

Output one line with one integer, representing how many $\rm{MB}$ of data Pero can use in month $n+1$.

Explanation/Hint

#### Sample 1 Explanation In the first month, Pero can use $10\rm{MB}$ of data. He actually uses $4\rm{MB}$, leaving $6\rm{MB}$. In the second month, Pero can use $6+10=16(\rm{MB})$ of data. He actually uses $6\rm{MB}$, leaving $10\rm{MB}$. In the third month, Pero can use $10+10=20(\rm{MB})$ of data. He actually uses $2\rm{MB}$, leaving $18\rm{MB}$. In the fourth month, Pero can use $18+10=28(\rm{MB)}$ of data. --- #### Constraints For $100\%$ of the testdata, it is guaranteed that $1\le x\le 100$, $1\le n\le 100$, and $0\le p_i\le 10^4$. ------------ #### Notes **This problem is translated from [COCI2016-2017](https://hsin.hr/coci/archive/2016_2017/) [CONTEST #1](https://hsin.hr/coci/archive/2016_2017/contest1_tasks.pdf) _T1 Tarifa_**. Translated by ChatGPT 5