#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int M,N,B[100];

bool isTokyo(int x){
	int w = 0, h = 1;
	for(int i=0;i<N;){
		if(w+B[i]>x){
			w = 0;
			if(++h>M) return true;
		}
		else w += B[i++];
	}
	return false;
}

int main(){
	while(cin>>M>>N,M||N){
		for(int i=0;i<N;i++) cin>>B[i];
		int l = 0, r = 1500000;
		while(l+1!=r){
			int piv = (l+r)/2;
			if(!isTokyo(piv)) r = piv;
			else l = piv;
		}
		printf("%d\n",r);
	}
	return 0;
}