#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int m, n;
	while (cin >> m >> n, m, n) {
		int w[110];
		int f = 0;
		for (int i = 0; i < n; i++) { cin >> w[i]; f = max(w[i], f); }
		while (1) {
			int p = 1, q = f;
			for (int i = 0; i < n; i++) {
				if (w[i] <= q)q -= w[i];
				else {
					p++;
					q = f - w[i];
				}
			}
			if (p <= m)break;
			f += 100;
		}
		cout << f << endl;
	}
}
