#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int INF=1e9;
int n, m;
vi d(110);

bool ok(int mid) {
	int cnt = 1, now = 0;
	rep(i, 0, n) {
		if (now + d[i] <= mid) {
			now += d[i];
		}
		else if (d[i] <= mid) {
			now = d[i];
			cnt++;
		}
		else {
			return false;
		}
	}
	//cout << mid << " " << (cnt <= m ? "ok" : "ng") << cnt << m << endl;
	return cnt <= m;
}

signed main() {
	while (1) {
		cin >> m >> n;
		if (n + m == 0) break;
		d.clear();
		rep(i, 0, n) {
			cin >> d[i];
		}
		int l = 1, r = 1500000;
		rep(i, 0, 100) {
			int mid = (l + r) / 2;
			if (ok(mid)) r = mid;
			else l = mid;
		}
		cout << r << endl;
	}
}