#include <iostream>
#include <string>
#include <vector>
using namespace std;

int m, n;
vector<int> books;

bool ok(int w) {
    int cnt = 1, sum = 0;
    for (int i=0; i<n; ++i) {
        if (w < books[i]) return false;
        if (w < sum + books[i]) {
            sum = books[i];
            cnt ++;
        } else {
            sum += books[i];
        }
    }
    return cnt <= m;
}

int main() {
    while (cin >> m >> n, m) {
        books.resize(n);
        for (int i=0; i<n; ++i) {
            cin >> books[i];
        }
        int l = 0;
        int h = 100000000;
        while (l < h) {
            int mid = (l + h) / 2;
            if (ok(mid)) {
                h = mid;
            } else {
                l = mid + 1;
            }
        }
        cout << l << endl;
    }
    return 0;
}