#include<cstdio>
#include<algorithm>
using namespace std;
int psum[128];
int m,n;
bool check(int mid){
	int now = 0;
	int D = 0;
	int cnt = 0;
	bool f = false;
	int x = 1000;
	while(x--){
		if(psum[now] < mid && !f)now++;
		else if(psum[now] == mid && !f){
			f = true;
			cnt++;
			D = now-1;
		}
		else if(f && psum[now]-psum[D] < mid)now++;
		else if(f && psum[now]-psum[D] == mid){
			cnt++;
			D = now-1;
		}
		else{
			f = true;
			cnt++;
			D = now-1;
		}
		if(now == n)break;
	}
	
	if(cnt > m-1)return false;
	else return true;
}
int main(){
	while(scanf("%d%d",&m,&n),(m|n)){
		int books[128];
		int sum = 0;
		int ma = -1000;
		for(int i = 0; i < n; i++){
			scanf("%d",&books[i]);
			sum += books[i];
			ma = max(ma,books[i]);
			if(i==0)psum[i] = sum;
			else psum[i] = psum[i-1]+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",mid);
	}
	return 0;
}
		