#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define INF (1<<28)
#define MAX_N 100
#define MAX_M (20+1)

int m, n;
int book[MAX_N];
int length[MAX_N];

int len(int from, int to) { // [from, to)
    return length[to] - length[from];
}

int dp[MAX_N][MAX_M];
int solve(int index, int rem) {
    if (rem == 1) return len(index, n);
    if (index == n) return 0;
    if (dp[index][rem] >= 0) return dp[index][rem];
    int min_len = INF;
    for (int i = index+1; i <= n; i++) {
        min_len = min(min_len, max(solve(i, rem-1), len(index, i)));
    }
    return dp[index][rem] = min_len;
}

void init() {
    for (int i = 0; i < n; i++) scanf("%d", &book[i]);
    length[0] = 0;
    for (int i = 1; i <= n; i++) 
        length[i] = length[i-1] + book[i-1];
    memset(dp, -1, sizeof(dp));
}

int main() {
    while (scanf("%d %d", &m, &n), m || n) {
        init();
        printf("%d\n", solve(0, m));
    }
    return 0;
}