#include <iostream>
#include<cstdio>
#include <cstring>	// require memset
#include <fstream>	// require freopen

using namespace std;

const int MaxW = 1500000;
int m, n;	// {IÌi 1  m  20, {Ìª 1  n  100
int w[100];

bool calc_m (int curr_w )
{
	int l[20];
	memset (l, 0, sizeof (l ) );

	int j = 0;
	for (int i = 0; i < n; i++ ){
		while (j < m && l[j] + w[i] > curr_w )
			j++;
		if (j == m )
			return false;
		l[j] += w[i];
	} // end for

	return true;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.persistence", "r", stdin );

	for (;; ){// {IÌ ans  1500000
		scanf ("%d%d", &m, &n ); if (!m ) break;
		memset (w, 0, sizeof (w ) );

		for (int i = 0; i < n; i++ ){
			scanf ("%d", w+i );
		} // end for
		int l = w[0];
		int r = MaxW;
		int mid = 0;
		int res = MaxW;
		while (l <= r ){
			mid = (l+r)/2;
			if (calc_m (mid ) ){
				res = min (res, mid );
				r = mid-1;		
			}else{
				l = mid+1;
			} // end if
		} // end while
		cout << res << endl;
	} // end loop
		
	return 0;
}