#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main( void )
{
	const int INF = ( 1 << 21 );

	int m, n;
	while ( cin >> m >> n && m > 0 && n > 0 )
	{
		vector <int> S(n+1,0);
		for ( int i = 1; i <= n; i++ )
			cin >> S[i];

		vector <int> P(n+1,0);
		for ( int i = 1; i <= n; i++ )
			P[i] = P[i-1] + S[i];

		vector < vector <int> > M( n+1, vector <int>( m+1, 0 ) );

		for ( int i = 1; i <= n; i++ )
			M[i][1] = P[i];

		for ( int i = 1; i <= m; i++ )
			M[1][i] = S[1];

		for ( int i = 2; i <= n; i++ )
		{
			for ( int j = 2; j <= m; j++ )
			{
				M[i][j] = INF;
				for ( int x = 1; x <= i - 1; x++ )
				{
					int maxv = max( M[x][j-1], P[i]-P[x] );
					if ( M[i][j] > maxv )
						M[i][j] = maxv;
				}
			}
		}

		cout << M[n][m] << endl;

	}

	return 0;
}