#include<cstdio>
#include<algorithm>
using namespace std;
int books[128];
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 = -1000;
		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;
}
		