#include <iostream>
#include <climits>

using namespace std;

int jagde( int *book, int ix, int n, int m )
{
	int sum;
	int j;

	sum = 0;
	j = 0;
	for( int i = 0;i < n;i++ ){
		sum += book[i];
		if( sum > ix ){
			j++;
			i--;
			sum = 0;
		}
	}
	if( j >= m ) return -1;

	ix--;

	sum = 0;
	j = 0;
	for( int i = 0;i < n;i++ ){
		sum += book[i];
		if( book[i] > ix ) return 0;
		if( sum > ix ){
			j++;
			i--;
			sum = 0;
		}
	}
	if( j >= m ) return 0;
	return 1;
}


int answer( int m, int n, int *book )
{
	int low,high;
	int sum[101];

	sum[0] = book[0];
	low = book[0];
	for( int i = 1;i < n;i++ ){
		if( low < book[i] ) low = book[i];
		sum[i] = sum[i - 1] + book[i];
	}

	high = sum[n - 1];

	while( true ){
		int ix = (low + high) / 2;
		int answer = jagde( book, ix, n, m );

		if( answer == -1 ){
			low = ix + 1;
		} else if( answer == 0 ) {
			return ix;
		} else if( answer == 1 ) {
			high = ix - 1;
		}
	}

}

int main(int argc, char const* argv[])
{
	int m,n;
	int book[101];

	while( cin >> m >> n && m != 0 ){
		for( int i = 0;i < n;i++ ) cin >> book[i];

		cout << answer( m, n, book ) << endl;
	}
	return 0;
}