#include <iostream>
#include <cstdio>
using namespace std;
const double EPS = 1e-9;

int n , m;
int book[100];
double simulate(double width){
	int height = 0;
	double remain = 0;
	for(int i = 0 ; i < n ; i++){
		if( remain - book[i] < -EPS){
			height++;
			remain = width; 
		}
		remain -= book[i];
		if( remain < -EPS) return false;
	}
	return height <= m;
}

int main(){
	while(cin >> m >> n && (m||n) ){
		for(int i = 0 ; i < n ; i++) cin >> book[i];
		int ans = 1e9;
		
		double l = 0 , r = 1500000;
		for(int i = 0 ; i < 128 ; i++){
			double mid = (l+r) / 2; //切り上げ(いろいろな都合で)
			if( simulate(mid) ){ //midで入れるのに成功したらrをmにする
				r = mid;
			}else{
				l = mid;		//midで入れるのに失敗したら
			}
		}
		printf("%.lf\n",l);
		/*
		for(int i = 0 ; i < n ; i++){
			int sum = 0;
			for(int j = i ; j < n ; j++){
				sum += book[j];
				if( simulate(sum) ) ans = min( ans , sum );
			}
		}
		cout << ans << endl;
		*/
	}
}