Problem2212--Homework

2212: Homework

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 200200 points

Problem Statement

Takahashi has NN days of summer vacation.
His teacher gave him MM summer assignments. It will take A_iAi days for him to do the ii-th assignment.
He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.
What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?
If Takahashi cannot finish all the assignments during the vacation, print -1 instead.

Constraints

  • 1 \leq N \leq 10^61N106
  • 1 \leq M \leq 10^41M104
  • 1 \leq A_i \leq 10^41Ai104

Input

Input is given from Standard Input in the following format:
NNMMA_1A1......A_MAM

Output

Print the maximum number of days Takahashi can hang out during the vacation, or -1.

Sample Input Copy

41 2
5 6

Sample Output Copy

30

HINT

For example, he can do the first assignment on the first 55 days, hang out on the next 3030 days, and do the second assignment on the last 66 days of the vacation. In this way, he can safely spend 3030 days hanging out.

Source/Category