#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <climits>
#include <queue>
#include <cstring>
using namespace std;
#define INF (1<<21)
#define rep(i,n) for(int i=0;i<n;i++)	
int solve(int &m,int &n,vector<int> &book){
	int ret = INF;
	int dp[n][n];	
	memset(dp,0,n*n*4);
	rep(i,n){
		for(int j=i;j<n;j++){
			if(i == j)dp[i][j] = book[j];
			else dp[i][j] = dp[i][j-1] + book[j];
		}
	}
	rep(x,n)rep(y,n){
		rep(i,n){
			int width = dp[x][y];
			int cur = i,p,sum = 0;
			
			if(dp[0][i] > width)continue;
			
			bool flag;
			//cout << "[" << width << "]" << endl;
			int count = 0;
			do{
				flag = true;
				p = cur+1;
				while( cur+1 < book.size() && dp[p][cur+1] <= width){
					cur++; flag = false;
				}
				count++;
			}while(!flag);

			if(cur == book.size()-1 && count <= m)
				ret = min(ret,width);
		}
	}
	return ret;
}
int main(){
	int n,m;
	while(cin >> m >> n,n){
		vector<int> book(n);
		rep(i,n)cin >> book[i];
		cout << solve(m,n,book) << endl;
	}
}