#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<queue>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define reps(i,n) for(int i=1;i<=int(n);i++)

#define f first
#define s second

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0)break;
		
		int hon[111];
		rep(i,m){
			cin>>hon[i];
		}
		
		double left=0;
		double right=15000001;
		
		while(1){
			double h=(left+right)/2;
			
			int dan=1;
			int now=0;
			rep(i,m){
				if(now+hon[i]>h){
					now=0;
					i--;
					dan++;
				}else{
					now+=hon[i];
				}
				if(dan>n)break;
			}
			
			if(dan>n){
				left=h;
			}else{
				right=h;
			}
			
			if(right-left<0.0001){
				printf("%d\n",(int)(right+0.001));
				break;
			}
		}
	}
}