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

int m,n,*b,*l,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 erase(){
	for(int i=1; i<m; i++)
		l[i] = 0;
}

void solve(int x, int y){
	l[x] = 0;
	for(int i=y; i<n; i++){
		l[x] += b[i];
		if(x != m-1)
			solve(x+1, i+1);
	}
	if(x == m-1){
//		for(int i=0; i<m; i++)
//			cout << l[i] << ' ';
//		cout << endl;
		hk[mp++] = max();
		if(hl[mp-1] < hk[mp])
			goto FIN;
		return;
	}
}

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];
		mp = 0;
		solve(0, 0);
FIN:;
		cout << min() << endl;
		delete[] b;
		delete[] l;
		hk.clear();
	}
}