This page is still under construction.

Parts of this page are still being built. What you see may change.

Data Plan

Interview

Time limit1sMemory limit64 MB

Summary
Track monthly data allowance that rolls over, subtract each month's usage, and report the megabytes available in month N+1.
Level

Easy2 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

Pero signed a data plan with his internet provider. The provider lets Pero use up to XX megabytes of internet per month. Every megabyte he does not spend during a month carries over to the next month and can still be spent. Pero can never spend more megabytes than he has left.

Given how many megabytes Pero spent in each of the first NN months on the plan, find how many megabytes Pero has available in month N+1N + 1.

Input

The first line contains the integer XX (1≤X≤1001 \le X \le 100).

The second line contains the integer NN (1≤N≤1001 \le N \le 100).

Each of the next NN lines contains an integer PiP_i (0≤Pi≤100000 \le P_i \le 10000), the number of megabytes spent in month ii on the plan. The input never makes Pero spend more megabytes than he has left.

Output

Print the number of megabytes Pero has available in month N+1N + 1.

Examples3

  1. Example 1

    Input
    10
    3
    4
    6
    2
    
    Expected output
    28
    
  2. Example 2

    Input
    10
    3
    10
    2
    12
    
    Expected output
    16
    
  3. Example 3

    Input
    15
    3
    15
    10
    20
    
    Expected output
    15