Question
Holiday Assignment Planner

Ethan has been given N assignments to finish over his M-day holiday break. Each assignment takes a specific number of days, Ai, and since he can only work on one assignment at a time, he wants to know how much free time he’ll have left for fun if he completes them all. Can you calculate the maximum number of days Ethan will have left to enjoy his holidays? If it’s impossible for him to finish all assignments within the break, return -1.

Input
The first line of the input consists of two positive integers, M and N
The next line contains N integers, ith integers of which represents the number of days taken to complete the ith assignment.

Constraints
1 ≤ M ≤ 2 x 106
1 ≤ N ≤ 2 x 104
1 ≤ Ai​ ≤ 2 x 104
Output
Print the maximum days left with Ethan.
Example
Sample Input
30 5
1 2 3 4 5
Sample Output
15

Online