#include <iostream>
using namespace std;

int main()
{
	int i,n,m,hon[100],max,dan,temp;
	while(cin >> m >> n, n || m){
		max = 0;
		for(i = 0;i < n;i++){
			cin >> hon[i];
			if(max < hon[i])
				max = hon[i];
		}
		dan = m + 1;
		for(i = max;dan > m;i++){
			dan = 1;
			temp = 0;
			for(int j = 0;j < n;j++){
				if(temp + hon[j] <= i){
					temp += hon[j];
				} else {
					temp = hon[j];
					dan++;
				}
			}
		}
		cout << i - 1 << endl;
	}
	return 0;
}