#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	int a, b;
	while (cin >>a>>b,a|b) {
		int ruisekiwa[101]; ruisekiwa[0] = 0;
		for (int d = 1; d <= b; d++) {
			int e; scanf("%d", &e);
			ruisekiwa[d] = ruisekiwa[d - 1] + e;
		}
		int dp[21][101];//n???????????§??§m?????????????°????
		for (int i = 0; i < 21; i++)fill(dp[i], dp[i] + 101, 1 << 29);
		dp[0][0] = 0;
		for (int i = 1; i <=a; i++) {
			for (int j = 1; j <= b; j++) {
				for (int k = j; k >= 0;k--) {
					dp[i][j] = min(dp[i][j], max(dp[i-1][j-k],ruisekiwa[j]-ruisekiwa[j-k]));
				}
			}
		}
		cout << dp[a][b] << endl;
	}
}