#include<iostream>
#include<algorithm>
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
int main(){
	int m,n;
	int M[101][21],S[101],P[101]={0};
	while(cin>>m>>n,m){
		rep1(i,n)cin>>S[i],P[i]=P[i-1]+S[i];
		rep1(i,n)rep1(j,m)if(i!=1&&j!=1){
			int t,mi,mn=1<<30;
			rep1(x,i-1){
				t=max(M[x][j-1],P[i]-P[x]);
				if(mn>t)mn=t,mi=x;
			}
			M[i][j]=mn;
		}else M[i][j]=(i-1?P[i]:S[1]);
		cout<<M[n][m]<<endl;
	}
	return 0;
}