#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n, m;
	while (cin >> m >> n, n || m) {
		int v[100];
		REP(i, n) scanf("%d", &v[i]);
		
		int sum[100];
		sum[0] = v[0];
		FOR(i,1,n) sum[i] = sum[i - 1] + v[i];
		
		int ans = 1;
		REP(i, n) ans = max(ans, v[i]);
		ans = max(ans, sum[n - 1] / m);
		
		while (true) {
			int cnt = 0, pos = 0;
			while (pos < n) {
				cnt++;
				if (cnt > m) break;
				
				int now = v[pos++];
				while (pos < n && now + v[pos] <= ans) now += v[pos++];
			}
			
			if (cnt <= m) {
				cout << ans << endl;
				break;
			}
			
			ans++;
		}
	}
	
	return 0;
}