#include <iostream>

using namespace std;

typedef unsigned long long ull;

int m, n;
ull w[100];

bool b(ull W)
{
	int need = 1;
	ull s = 0;
	for(int i=0; i<n; i++)
	{
		if(w[i] > W) return false;
		if(s+w[i]>W)
		{
			need++;
			s = 0;
		}
		s+=w[i];
	}
	return need <= m;
}

int main()
{
	while( 1 )
	{
		scanf("%d", &m);
		scanf("%d", &n);
		if((m|n)==0) break;
		
		for(int i=0; i<n; i++) scanf("%llu", &w[i]);
		
		ull l = 1;
		ull r = 150000;
		while(r-l > 1)
		{
			ull mid = (r + l) / 2;
			if(b(mid)) r = mid;
			else l = mid;
		}

		printf("%llu\n", b(l)?l:r);
	}
}