#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int m, n;
int book[105];

bool check(int bre)
{
	int cnt = 0;
	int tmp = 0;
	REP(i, n)
	{
		if (cnt > m || book[i]>bre) return false;
		if (tmp + book[i] > bre)
		{
			cnt++;
			tmp = book[i];
		}
		else
		{
			tmp += book[i];
		}
	}
	return cnt < m;
}

int main()
{
	while (cin >> m >> n, m)
	{
		REP(i, n) cin >> book[i];
		int lb = 0; int ub = 2000000;
		while (ub - lb > 1)
		{
			int mid = (ub + lb) / 2;
			if (check(mid)) ub = mid;
			else lb = mid;
		}
		cout << ub << endl;
	}
	return 0;
}