//21
#include<iostream>
#include<algorithm>
#include<numeric>

using namespace std;

int m,n;
int w[100];
int memo[21][100];

int mw(int rm,int f){
  if(rm==1){
    return accumulate(w+f,w+n,0);
  }else if(memo[rm][f]!=-1){
    return memo[rm][f];
  }else{
    int mnw=1<<30;
    for(int i=f;i<n;i++){
      mnw=min(mnw,max(accumulate(w+f,w+i,0),mw(rm-1,i)));
    }
    memo[rm][f]=mnw;
    return mnw;
  }
}

int main(){
  while(cin>>m>>n,m|n){
    fill(memo[0],memo[21],-1);
    for(int i=0;i<n;i++){
      cin>>w[i];
    }
    cout<<mw(m,0)<<endl;
  }
  return 0;
}