Problem1286--Boxing problem

1286: Boxing problem

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

Description

There is a box with a capacity of V (positive integer, o≤v≤20000), at the same time there are n items (o≤n≤30), each item has a volume (positive integer). Requirements from n items, if thousands of loaded into the box, so that the remaining space for the box is the smallest.

Input

The first line, an integer, represents the box capacity;
The second line, an integer, indicates that there are n items; The next n lines, respectively, represent the respective volumes of the N items.

Output

An integer that represents the remaining space of the box.

Sample Input Copy

24
6
8
3
12
7
9
7

Sample Output Copy

0

HINT

动态规划

Source/Category

vijos