#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0181 : Persistence **/
int M, N;
int W[100];

bool check(int w)
{
	int cw=0, cm=1;
	rep(i, N) {
		if (W[i]>w) return false;
		
		if (cw+W[i]>w) {
			cm++;
			cw=0;
		}
		cw+=W[i];
	}
		
	return cm<=M;
}

int main()
{
	while (cin>>M>>N, M||N) {
		rep(i, N) {
			cin>>W[i];
		}
		
		int l=0, u=1500000;
		while (u-l>1) {
			int mid = (l+u)/2;
			if (check(mid)) {
				u=mid;
			} else {
				l=mid;
			}
		}
		
		cout << u << endl;
	}
}