#include <iostream>
using namespace std;

int main()
{
	int m, n;
	while( cin >> m >> n && ( m || n ) ){
		int book[ 100 ] = {0};
		int acum = 0;
		int sum[ 100 ] = {0};
		for( int i = 0; i < n; ++i ){
			int t;
			cin >> t;
			book[ i ] = t;
			acum += t;
			sum[ i ] = acum;
		}
		int ans = 0x7fffffff;
		for( int i = 0; i < n; ++ i ){
			int shelf[ 20 ] = {0};
			int ib = i + 1;
			int is = 1;
			while( ib < n && is < m ){
				int w = shelf[ is ] + book[ ib ];
				if( w <= sum[ i ] ){
					++ib;
					shelf[ is ] = w;
				}else{
					++is;
				}
			}
			if( ib == n && ans > sum[ i ] ){
				ans = sum[ i ];
			}
		}
		cout << ans << endl;
	}

	return 0;
}