Problem A: 装箱问题Reserved

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:96 Solved:39

Description

有一个箱子容量为 v(正整数,0≤v≤20000),同时有 n 个物品(0<n≤30),每个物品有一个体积(正整数)。
要求从 n 个物品中,任取若干个装入箱内,使箱子的剩余空间为最小。

Input

箱子的容量 v
物品数 n
接下来 n 行,分别表示这 n 个物品的体积

Output

箱子剩余空间

Sample Input Copy

24
6
8
3
12
7
9
7

Sample Output Copy

0