#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int m,n;
    while(cin>>m>>n,m){
        int b[200];
        int max_b = 0;
        for(int i = 0;i < n;i++){
            cin>>b[i];
            max_b = max(max_b,b[i]);
        }

        int D = 100;
        int l = 1,r = 1500001;
        int ans = 1600000;
        while(D--){
            int mid = (l+r)/2;
            if(mid < max_b){
                l = mid;
                goto next;
            }
            {
                int idx = 0,br = 0;
                for(int i = 0;i < n;i++){
                    if(br + b[i] <= mid)br = br + b[i];
                    else{
                        idx++;
                        br = b[i];
                        if(idx == m){
                            l = mid;
                            goto next;
                        }
                    }
                }
            }
            r = mid;
            next:;
        }
        cout<<r<<endl;
    }



    return 0;
}