#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#define MAX_M 1500000
#define MIN_M 0
using namespace std;
int book[101];
int main(void)
{
	ios::sync_with_stdio(false);
	int i,j,k;
	int m,n;
	int low,high,mid,ff;
	int tanasuu,sum,mx;
	while(1) {
		cin>>m>>n;
		if(m==0&&n==0) break;
		low=MIN_M;
		high=MAX_M;
		mx=MIN_M;
		ff=0;
		for(i=0;i<n;i++) cin>>book[i];
		while(low<=high) {
			mid=(low+high)/2;
			sum=MIN_M;tanasuu=1;
			for(j=0;j<n;j++) {
				/*if(mid==sum+book[j]) tanasuu++;
				else if(mid>sum+book[j])sum+=book[j];
				else if(mid>book[j]){
					tanasuu++;
					sum=book[j];
				}	
				if(tanasuu<m && mid==sum+book[j]) {
					tanasuu++;
					sum=0;
				}
				else if(mid>sum+book[j]) {
					tanasuu++;
					if(mid>=book[j]) {
						sum=book[j];
					}
					else break;					
				}*/
				if(m<n) {
					if(tanasuu<=m) {
						if(mid==sum+book[j]) {
							tanasuu++;
							sum+=book[j];
						}
						else if(mid>sum+book[j]) {
							sum+=book[j];
						}
						else {
							if(mid>=book[j]) {
								sum=book[j];
								tanasuu++;
							}
						}
					}
					else break;
				}
				else {
					ff=1;
					if(mx<book[j]) mx=book[j];
				}
			}
			if(ff==0) {
				if(tanasuu>m){
					low=mid+1;
				}
				else high=mid-1;
			}
			else break;
		}
		if(ff==0) 
			cout<<high<<endl;
		else cout<<mx<<endl;
	}	
	return 0;
}	