#include<cstdio>
#include<iostream>
#include<vector>

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

using namespace std;

int main(){
	
	while(1){
		int n,m;
		int hon[100];
		sintt(n,m);
		if(n==0)break;
		rep(i,m){
			sint(hon[i]);
		}
		
		
		int left=0;
		int right=0;
		
		rep(i,m){
			right+=hon[i];
		}
		
		while(1){
			double harf= (double)(right+left)/2;
			//printf("%d %lf %d\n",left,harf,right);
			
			if(right==left){
				break;
			}
			
			int flg=0;
			int sum=0;
			int dan=0;
			for(int i=0;i<m;i++){
				
				if(dan>n){
					break;
				}
				
				if(sum+hon[i]>harf){
					sum=0;
					i--;
					dan++;
					continue;
				}else{
					sum+=hon[i];
				}
			}
			
			if(dan<n){
				flg=1;
			}
			
			if(flg==1){
				right=harf;
			}else{
				left=(int)((double)harf+0.5);
			}
		}
		printf("%d\n",right);
	}
}
/*
3 9
500
300
800
200
100
600
900
700
401

*/