Logo
(追記) (追記ここまで)

13484번 - Tarifa 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 64 MB89377974588.061%

문제

Pero has negotiated a Very Good data plan with his internet provider. The provider will let Pero use up X megabytes to surf the internet per month. Each megabyte that he doesn’t spend in that month gets transferred to the next month and can still be spent. Of course, Pero can only spend the megabytes he actually has.

If we know how much megabytes Pero has spent in each of the first N months of using the plan, determine how many megabytes Pero will have available in the N + 1 month of using the plan.

입력

The first line of input contains the integer X (1 ≤ X ≤ 100).
The second line of input contains the integer N ​(1 ≤ N ≤ 100).
Each of the following N lines contains an integer Pi (0 ≤ Pi ​≤ 10 000), the number of megabytes spent in each of the first N months of using the plan. Numbers Pi will be such that Pero will never use more megabytes than he actually has.

출력

The first and only line of output must contain the required value from the task.

제한

예제 입력 1

10
3
4
6
2

예제 출력 1

28

예제 입력 2

10
3
10
2
12

예제 출력 2

16

예제 입력 3

15
3
15
10
20

예제 출력 3

15

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2016/2017 > Contest #1 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /