#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int m,n,book[101]={0};
        int nowans,nowmin=0,nowmax=1500001;
        scanf("%d %d",&m,&n);
        if(m==0&&n==0)
            break;
        for(int i=0;i<n;i++)
            scanf("%d",&book[i]);
        for(int i=0;i<100;i++){
            int po=0;
            int dan[21]={0};
            nowans=(nowmin+nowmax)/2;
            for(int j=0;j<n+1;j++){
                if(j==n){
                    nowmax=nowans;
                    break;
                }
                if(dan[po]+book[j]<=nowans){
                    dan[po]+=book[j];
                    continue;
                }
                else if(book[j]>nowans){
                    nowmin=nowans;
                    break;
                }
                else if(dan[po]+book[j]>nowans){
                    po++;
                    if(po==m){
                        nowmin=nowans;
                        break;
                    }
                    dan[po]+=book[j];
                }
            }
        }
        printf("%d\n",nowans+1);
    }
}