#include <iostream>

using namespace std;

typedef unsigned long long ull;

int m, n;
double avg;
ull books[100];
ull min_w = 150001;

void solve(ull max_w, int i, int depth)
{
	if(depth <= m && i==n)
	{
		min_w = (max_w < min_w) ? max_w : min_w;
		return;
	}
	
	ull w = 0;
	for(int k=i; k<n; k++)
	{
		w += books[k];
		ull new_max_w = (max_w < w) ? w : max_w;
		solve(new_max_w, k+1, depth+1);
	}
}

int main()
{
	while( 1 )
	{
		scanf("%d", &m);
		scanf("%d", &n);
		if(m==0 && n==0) break;
		
		for(int i=0; i<n; i++)
		{
			scanf("%llu", &books[i]);
		}
		avg /= (float)n;

		min_w = 1500001;
		solve(0, 0, 0);
		printf("%llu\n", min_w);
	}
}