#t392. 装箱问题(boxes)

装箱问题(boxes)

Box Loading Problem

Problem Background

Special for beginners, ^_^

Problem Description

There is a box of capacity vv (a positive integer, 0≤v≤200000 \le v \le 20000), and at the same time there are nn items (0<n≤300 < n \le 30), each with a volume (a positive integer).

You are to pick some of the nn items to put into the box, so that the remaining space in the box is minimized.

Input Format

The capacity vv of the box.

The number of items nn.

The next nn lines, each giving the volume of one of the nn items.

Output Format

The remaining space in the box.

Sample Input

24
6
8
3
12
7
9
7

Sample Output

0

Constraints

Time limit: 1s, memory limit: 1024KiB for each test case.