#include "bits/stdc++.h"
using namespace std;
int books[105];
int m,n;
bool check(int mid){
    int now = 0; int d = 0; int l = 0;
    while(now < n && d < m){
        if(l + books[now] <= mid){
            l += books[now++];
        }
        else{
            d++; l = 0;
        }
    }
    if(d > m-1)return false;
    else return true;
}
int main(){
    while(scanf("%d%d",&m,&n),(m|n)){
        int sum = 0;
        int ma = -1;
        for(int i = 0; i < n; i++){
            scanf("%d",&books[i]);
            sum += books[i];
            ma = max(ma,books[i]);
        }

        int l = ma,r = sum;
        int mid=0;
        for(int i = 0;i < 100; i++){
            mid = (l+r)/2;
            if( check(mid) ){
                r = mid;
            }
            else l = mid;
        }
        printf("%d\n",r);
    }
    return 0;
}