#include <iostream>
#include <climits>

using namespace std;

int jagde( int *book, int ix, int n, int m )
{
	int hoge[101];
	int j;

	for( int i = 0;i < 101;i++ ) hoge[i] = ix;

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

	j = 0;
	for( int i = 0;i < n;i++ ){
		hoge[j] -= book[i];
		while( hoge[j] < 0 ){
			j++;
			if( j >= m ) return 0;
			hoge[j] -= book[i];
		}
		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];
	for( int i = 1;i < n;i++ ){
		sum[i] = sum[i - 1] + book[i];
	}

	low = 0;
	high = sum[n - 1];

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

		if( answer == -1 ){
			low = ix;
		} else if( answer == 0 ) {
			return ix;
		} else if( answer == 1 ) {
			high = ix;
		}
	}
	return -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;
}