#include <iostream>
#include <algorithm>
#define MAX 100
using namespace std;

int m, n;
int w[MAX];

bool c(int x) {
    bool used[n];
    fill(used, used + n, false);
    for (int i = 0; i < m; i++) {
        int sum = 0;
        for (int j = 0; j < n; j++) {
            if (used[j]) continue;
            if (sum + w[j] <= x) {
                sum += w[j];
                used[j] = true;
            } else {
                break;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (!used[i]) return false;
    }
    return true;
}

int main() {
    while (true) {
        cin >> m >> n;
        if (m == 0 && n == 0) return 0;
        for (int i = 0; i < n; i++) {
            cin >> w[i];
        }
        
        int l = 0, r = 1500001;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (c(mid)) r = mid;
            else l = mid;
        }
        cout << r << endl;
    }
}