Data Plan
InterviewTime limit1sMemory limit64 MB
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 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 months on the plan, find how many megabytes Pero has available in month .
Input
The first line contains the integer ().
The second line contains the integer ().
Each of the next lines contains an integer (), the number of megabytes spent in month 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 .