| 记录编号 | 
        223788 | 
        评测结果 | 
        AAAAA | 
    
    
        | 题目名称 | 
        1089.[NOIP 2001PJ]装箱问题 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         BH2 | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.021 s  | 
    
    
        | 提交时间 | 
        2016-02-13 15:01:56 | 
        内存使用 | 
        4.17 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		/* ***********************************************
Author        :guanjun
Created Time  :2016/2/13 14:28:42
File Name     :1.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
    return a>b;
}
int a[maxn];
int dp[50][20010];
int main()
{
    //#ifndef ONLINE_JUDGE
    freopen("npack.in","r",stdin);
    //#endif
    freopen("npack.out","w",stdout);
    //dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i]]+a[i])
	cle(dp);
	int n,v;
	while(cin>>v>>n){
		for(int i=1;i<=n;i++)cin>>a[i];
		for(int i=1;i<=n;i++){
			for(int j=1;j<=v;j++){
			
				if(a[i]>j){
					dp[i][j]=dp[i-1][j];
				}
				else{
					dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i]]+a[i]);
				}
			}
		}
		//cout<<dp[n][v]<<endl;
		cout<<v-dp[n][v]<<endl;
	}
    return 0;
}