#567. 装箱问题(boxes)

装箱问题(boxes)

Background

Special for beginners, ^_^

Description

有一个箱子容量为 vv(正整数,0v200000\le v\le 20000),同时有 nn 个物品(0<n300\lt n\le 30),每个物品有一个体积(正整数)。

要求从 nn 个物品中,任取若干个装入箱内,使箱子的剩余空间为最小。

Format

Input

箱子的容量 vv

物品数 nn

接下来 nn 行,分别表示这 nn 个物品的体积。

Output

箱子剩余空间。

Samples

24
6
8
3
12
7
9
7
0

Limitation

1s, 1024KiB for each test case.