#include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
bool ok(int m, int n, int s[100], int width) {
	int cnt = 0, size = s[0];
	rep2(i,1,n) {
		if(width<size) return false;
		if(width<size+s[i]) {
			size = 0;
			cnt++;
		}
		size += s[i];
	}
	if(size>0)cnt++;
	if(m>=cnt) return true;
	return false;
}
int main(){
	int m, n;
	while(cin >> m >> n, (m||n)) {
		int s[100] = {};
		rep(i,n) {
			cin >> s[i];
		}
		int lo = 0, hi = 1500000;
		while(hi-lo>=1) {
			int mid = (hi+lo)/2;
			if(ok(m,n,s,mid)) hi = mid;
			else lo = mid+1;
		}
		cout << hi << endl;
	}
	return 0;
}