#include <stdio.h>
 
int main(){
    int m,n;
    long int book[124]={0};
    int i,j;
    long int sum=0;
    long int x;
    int count;
    int sum2=0;
    int judge;
    
    scanf("%d %d\n",&m,&n);
    do{
    for(i=0;i<n;i++){
        scanf("%ld\n",&book[i]);
        sum+=book[i];
    }
    x=sum/m;
    sum2=0;
    for(i=0;i<200;i++){
        sum2+=book[i];
        if(sum2>x){
            judge=i-1;
            break;
        }
    }
    //printf("%d\n",x);
    for(j=judge;j<n;j++){
        count=1;
        x=0;
        for(i=0;i<=j;i++){
            x+=book[i];
        }
        //printf("%d %d %d %d\n",sum,judge,sum2,x);
        sum2=0;
    for(i=0;i<n;i++){
        sum2+=book[i];
        if(sum2>x){
            sum2=book[i];
            count++;
        }
    }
    //printf("count %d\n",count);
    if(count<=m){
        break;
    }
    }
    printf("%ld\n",x);
    scanf("%d %d\n",&m,&n);
    }while (m!=0||n!=0);
    return 0;
    
}