eolymp
Competitions

Huseyn and knapsack

Knapsack

Time limit 1 second
Memory limit 128 MiB

Find the maximum weight of gold that can be carried out in a knapsack of capacity s, if there are n gold ingots with specified weights.

Input data

The first line contains one number s (1s10^4). Then given n (1n300) non-negative integers, not exceeding 10^5 - the weights of ingots.

Output data

Print the desired maximum weight.

Examples

Input example #1
10
1 4 8
Output example #1
9
Input example #2
20
5 7 12 18
Output example #2
19