P29331 [洛谷] [COCI2016-2017#1] Tarifa
普及-
题目描述

Problem Description

To surf the internet, Pero has purchased a data plan:

  • Each month, he receives $x$ MB of data.
  • Any unused data from a month can be carried over to the next month.

Given the amount of data Pero used each month for the first $n$ months of this plan, calculate how much data he can use in the $(n+1)$-th month.

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$, representing the amount of data Pero used in the $i$-th month.

Output Format

A single line containing an integer, representing the amount of data Pero can use in the $(n+1)$-th month.

Sample Input and Output

Sample Input #1

10
3
4
6
2

Sample Output #1

28

Sample Input #2

10
3
10
2
12

Sample Output #2

16

Sample Input #3

15
3
15
10
20

Sample Output #3

15

Notes

Sample 1 Explanation

In the first month, Pero can use $10$ MB of data, but he uses only $4$ MB, leaving $6$ MB.

In the second month, Pero can use $6 + 10 = 16$ MB of data, but he uses only $6$ MB, leaving $10$ MB.

In the third month, Pero can use $10 + 10 = 20$ MB of data, but he uses only $2$ MB, leaving $18$ MB.

In the fourth month, Pero can use $18 + 10 = 28$ MB of data.


Data Constraints

For $100\%$ of the data, 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 CONTEST #1 T1 Tarifa.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
10 3 4 6 2
样例输出
28