#P6284. [COCI 2016/2017 #1] Tarifa

[COCI 2016/2017 #1] Tarifa

Description

To be able to surf the Internet, Pero bought a data plan:

  • Each month, he gets xMBx \rm{MB} of data.
  • Any unused data from a month can be carried over to the next month.

Now we know how many MB\rm{MB} of data Pero used in each of the first nn months of this plan. Please calculate how many MB\rm{MB} of data he can use in month n+1n+1.

Input Format

The first line contains an integer xx.

The second line contains an integer nn.

The next nn lines each contain an integer pip_i, which indicates how many MB\rm{MB} of data Pero used in month ii.

Output Format

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

10
3
4
6
2 
28
10
3
10
2
12 
16
15
3
15
10
20 
15

Hint

Sample 1 Explanation

In the first month, Pero can use 10MB10\rm{MB} of data. He actually uses 4MB4\rm{MB}, leaving 6MB6\rm{MB}.

In the second month, Pero can use 6+10=16(MB)6+10=16(\rm{MB}) of data. He actually uses 6MB6\rm{MB}, leaving 10MB10\rm{MB}.

In the third month, Pero can use 10+10=20(MB)10+10=20(\rm{MB}) of data. He actually uses 2MB2\rm{MB}, leaving 18MB18\rm{MB}.

In the fourth month, Pero can use 18+10=28(MB)18+10=28(\rm{MB)} of data.


Constraints

For 100%100\% of the testdata, it is guaranteed that 1x1001\le x\le 100, 1n1001\le n\le 100, and 0pi1040\le p_i\le 10^4.


Notes

This problem is translated from COCI2016-2017 CONTEST #1 T1 Tarifa.

Translated by ChatGPT 5