#include<iostream>

using namespace std;

int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n==0 && m==0){
			break;
		}
		int hon[150];
		for(int i=0;i<m;i++){
			cin>>hon[i];
		}
		
		int right,left;
		right=left=0;
		
		for(int i=0;i<m;i++){
			left+=hon[i];
		}
		
		while(1){
			double h=(double)(left+right)/2;
			//printf("%d %d %lf\n",right,left,h);
			
			int ans=0;
			
			int now=0;
			int dan=1;
			for(int i=0;i<m;i++){
				if(now+hon[i]>h){
					if(now==0){
						dan=100000;
						break;
					}
					now=0;
					dan++;
					i--;
					continue;
				}
				now+=hon[i];
			}
			
			//printf("%lf zi dan = %d\n",h,dan);
			
			if(dan<=n){
				ans=1;
			}
			if(ans==1){
				left=h+0.499;
			}else{
				right=h;
			}
			if((int)left==(int)right+1){
				printf("%d\n",left);
				break;
			}
		}
	}
}