Knapsack#4831

Knapsack

1 second
128 megabytes
Medium

Find the maximum weight of gold that can be carried in a knapsack with a capacity of , if gold bars are given with specified weights.

Input

The first line contains one number (1 \le s \le 10^4) — the knapsack capacity. Then follow (1 \le n \le 300) non-negative integers, not exceeding 10^5 — the weights of bars.

Output

Print the maximum weight of gold that can be carried in the knapsack.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading