#include <stdio.h>


long w[100];
int m,n;
long haba[20];
long minhaba=1500000L;


int gethaba(){
        int i;
        long maxhaba=0;
        for(i=0;i<m;i++)
                if(haba[i]>maxhaba)
                        maxhaba=haba[i];

        //printf("maxhaba=%ld\n",maxhaba);

        if(minhaba>maxhaba)
                minhaba=maxhaba;


        /*
                for(i=0;i<m+1;i++)
                        printf("haba %d: %ld\n",i,haba[i]);
        */
        return 0;
}


int oitemiru(int oku,int dan){
        int i;
        for(i=dan;i<=dan+1&&i<m;i++){
                haba[i]+=w[oku];
                if(oku>0)
                        oitemiru(oku-1,i);
                else
                        gethaba();
                haba[i]-=w[oku];
        }
}


main(){
        int i;

        while(1){
                scanf("%d %d",&m,&n);
                if(m==0)break;
                for(i=0;i<n;i++)scanf("%ld",&w[i]);
                for(i=0;i<m;i++)haba[i]=0;
                minhaba=1500000L;

                oitemiru(n-1,0);
                printf("%ld\n",minhaba);
        }
        return 0;
}