#include <iostream>
#include <vector>
#include <algorithm>
#define ALL(A) A.begin(), A.end()

using namespace std;

int main()
{
	int m, n;	// {IÌi 1  m  20, {Ìª 1  n  100

	while (cin >> m >> n && m && n ){
		vector <int> w (n, 0 );	// {Ì 1  w[i]  1000000
		int res = 0;				// {IÌ ans  1500000
		for (int i = 0; i < n; i++ ){
			cin >> w[i];
		} // end for

		if (m >= n ){
			res = w[max_element (ALL(w)) - w.begin()];
		}else{
			int curr_w = w[0];
			for (int i = 1; i < n; i++ ){
				curr_w += w[i];
				int cm = 1;
				int j = i+1;
				while (j < n && cm <= m ){
					int cw = 0;
					while (cw + w[j] <= curr_w && j < n ){
						cw += w[j];
						j++;
					} // end while
					cm++;
				} // end while
				if (cm <= m ){
					res = curr_w;
					break;
				} // end if
			} // end for
		} // end if

		cout << res << endl;

	} // end loop
		
	return 0;
}