#include <iostream>
#include <map>
using namespace std;

int m,n,*b,*l,a,t,mp;
map<int,int> hk;

int max(){
	int tmp = l[0];
	for(int i=1; i<m; i++)
		if(tmp < l[i])
			tmp = l[i];
	return tmp;
}

void solve(){
	mp = 0;
	int k;
	l[0] = 0;
	for(int i=0; i<n; i++){
		k = i+1;
		l[0] += b[i];
		for(int j=1; j<m-1; j++){
			l[j] = 0;
			for(; k<n; k++){
				l[j] += b[k];
				if(k == n-1){
					k++;
					break;
				}
				if((l[j] - l[0] >= 0 && l[j] - l[0] < b[k+1])||(l[j] >= l[0])){
					k++;
					break;
				}
			}
		}
		l[m-1] = 0;
		for(; k<n; k++)
			l[m-1] += b[k];
		if(k == n){
			hk[mp] = max();
			mp++;
		}
	}
}

int min(){
	int tmp = hk[0];
	map<int, int>::iterator it = hk.begin();
	while(it!=hk.end()){
		if(tmp > (*it).second)
			tmp = (*it).second;
		it++;
	}
	return tmp;
}

int main(){
	while(true){
		cin >> m >> n;
		if(!m && !n)
			return 0;
		b = new int[n];
		l = new int[m];
		for(int i=0; i< n; i++)
			cin >> b[i];
		solve();
		cout << min() << endl;
		delete[] b;
		delete[] l;
		hk.clear();
	}
}