#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int m, n;
        cin >> m >> n;
        if(m == 0)
            return 0;

        vector<int> book(n+1);
        book[0] = 0;
        cin >> book[1];
        for(int i=2; i<=n; ++i){
            cin >> book[i];
            book[i] += book[i-1];
        }

        int a = 1;
        int b = 1500000;
        while(a != b){
            int c = (a + b) / 2;
            int k = 1;
            for(int i=0; i<m; ++i){
                k = upper_bound(book.begin()+k, book.end(), book[k-1] + c) - book.begin();
                if(k == n+1)
                    break;
            }

            if(k == n+1)
                b = c;
            else
                a = c+1;
        }

        cout << a << endl;
    }
}