#include <iostream>

using namespace std;

int main(){
	while(true){
		int n, m;
		cin >> m >> n;
		if(n == 0 && m == 0){ break; }
		int iw[100];
		cin >> iw[0];
		for(int i = 1; i < n; i++){
			cin >> iw[i];
			iw[i] += iw[i - 1];
		}
		int left = 0, right = 1500000, answer = 0;
		while(left < right){
			int center = (left + right) / 2;
			bool flag = false;
			for(int i = 0, f = 0, p = 0; i < m; i++){
				for(; f < n; f++){
					if(iw[f] - p > center){ break; }
				}
				if(f == n){ flag = true; break; }
				if(f == 0 || iw[f] == p){ break; }
				p = iw[f - 1];
			}
			if(flag){
				answer = center;
				right = center;
			}else{
				left = center + 1;
			}
		}
		cout << answer << endl;
	}
	return 0;
}