#include <iostream>
#include <cstring>

using namespace std;

#define BOOK_NUM_MAX 100
#define SHELF_NUM_MAX 20

int book_thick[BOOK_NUM_MAX] = {0};
int dp_table[SHELF_NUM_MAX][BOOK_NUM_MAX] = {-1};

int solve(int m, int n){
	int sum, val, min, tmp;
	
	if(dp_table[m][n] == -1){
		if(m == 1){
			sum = 0;
			for(int i=1; i <= n;++i){
				sum += book_thick[n - i];
			}
			val = sum;
		}else if(n == 0){
			val = 0;
		}else{
			sum = 0;
			min = solve(m-1, n);
			for(int i=1; i <= n;++i){
				sum += book_thick[n - i];
				tmp = solve(m-1,n-i);
				tmp = sum > tmp ? sum : tmp;
				min = min > tmp ? tmp : min; 
			}
			val = min;
		}
		dp_table[m][n] = val;
	}else{
		val = dp_table[m][n];
	}
	return val;
}

int main() {
	
	int m, n;
	int i,j;
	
	while(cin >> m >> n, m!= 0 && n!= 0){
		for(i=0;i<n;++i){
			cin >> book_thick[i];
		}
		memset(dp_table    , -1, sizeof(dp_table));

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