#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define reps(i,n) for(int i=1;i<=int(n);i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);

#define INF 1010000000
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
	while(1){
		int n,m;
		sintt(m,n);
		if(n==0)break;
		int hon[101];
		rep(i,n){
			sint(hon[i]);
		}
		
		int left=0;
		int right=1000000;
		
		while(1){
			double harf=(right+left)/2.0;
			
			int flg=0;
			
			int now=0;
			int cont=0;
			rep(i,n){
				if(now+hon[i]<=harf){
					now+=hon[i];
				}else{
					now=0;
					i--;
					cont++;
				}
				if(cont>=m){
					break;
				}
			}
			
			if(cont>=m){
				flg=1;
			}
			
			if(flg==1){
				left=harf+0.5;
			}else{
				right=harf;
			}
			
			if(left==right){
				printf("%d\n",left);
				break;
			}
		}
	}
}