01背包板子
#include<bits/stdc++.h>
using namespace std;
const int N = 33;
int v[N] , f[200010];
int n , m;
int main()
{
cin >> m >> n;
memset (f , 0 , sizeof f);
for (int i = 1 ; i <=n ; i ++)
cin >> v[i];
for (int i = 1; i <= n; i ++)
for (int j = m; j >= v[i] ; j --)
f[j] = max( f[j] , f[j - v[i]] + v[i]);
cout << m - f[m] <<endl;
}