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

#define INF (1<<28)
#define MAX_N 100

int m, n;
int book[MAX_N];

int len(int from, int to) { // [from, to)
    int l = 0;
    for (int i = from; i < to; i++) {
        l += book[i];
    }
    return l;
}

int solve(int index, int rem, int max_len) {
    if (rem == 1) return max(max_len, len(index, n));
    if (index == n) return max_len;
    int min_len = INF;
    for (int i = index+1; i <= n; i++) {
        min_len = min(min_len, solve(i, rem-1, max(max_len, len(index, i))));
    }
    return min_len;
}

int main() {
    while (scanf("%d %d", &m, &n), m || n) {
        for (int i = 0; i < n; i++) scanf("%d", &book[i]);
        printf("%d\n", solve(0, m, 0));
    }
    return 0;
}