#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<sstream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cctype>
#include<cmath>
#include <fstream>	// require freopen
using namespace std;
#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) REP(i,0,n)
int b[100],m,n;
bool C(int d)
{
  int v[20]; rep(i,m)v[i]=0;
  int ii=0;
  rep(i,n){
    while(ii<m && v[ii]+b[i]>d)ii++;
    if(ii==m)return false;
    v[ii]+=b[i];
  }
  return true;
}
int main(void)
{
//	cut here before submit 
//	freopen ("testcase.persistence", "r", stdin );

  for(;;){
    scanf("%d%d",&m,&n); if(!m)break;
    rep(i,n) scanf("%d",b+i);
    int l,r,mid,res=9999999;
    l=0; r=1500000;
    while(l<=r){
      mid=(l+r)/2;
      //printf("%d %d %d\n",l,mid,r);
      if(C(mid)){
	res=min(res,mid);
	r=mid-1;
      }
      else l=mid+1;
    }
    printf("%d\n",res);
  }
}