#include<iostream>
using namespace std;
int s[1001];
int b[1001];
int m, n;
int nb;
int w;
//find max x s[x]<=w+s[nb-1];
int se() {
	int be = nb;
	int en = n;
	int bb=-1;
	int ee = -1;
	for (; en - be>0;) {
		int mid = (be + en) / 2;
		if (w + s[nb-1] >= s[mid]) {
			be = mid;
			if (bb == be)
				en--;
			else
				bb = be;

		}
		else {
			en = mid;
			if (ee == en)
				en--;
			else
				ee = en;
		}
		

	}
	
	if (be + 1 <= n)
		if (s[be+1] <= w + s[nb - 1])
			return be + 1;
	if (s[be] <= w + s[nb - 1])
		return be;
	else
		return -1000;
}

int main() {
	s[0] = 0;
	while (cin >> m >> n, m) {
		int i;
		int nm;
		for (i = 0; i < n; i++)
			cin >> b[i];
		for (i = 1; i <= n; i++)
			s[i] = s[i - 1] + b[i-1];
		for (w = 1; w <= 1500000; w++) {
			nb = 1;
			for (nm = 1; nm <= m&&nb<=n; nm++) {
				nb = se();
				if (nb < 0)
					break;
				nb++;
				
			}
			if (nb > n)
				break;

		}
		cout << w << endl;




	}
	return 0;
}