// AOL Q.0181
// YAMADA Terushige 2013.4.3.
 
#include<iostream>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
 
using namespace std;

int M,N,D[100];

bool store(int w){
  int sum=0;
  int dan=1;
  for(int i=0;i<N;i++){
    sum+=D[i];
    if(sum>w){
      sum=0;
      dan++;
      if(dan > M) return false;
      i--;
    }      
  }
  return true;
}
 
int main(){
  int wmin,wmid,wmax;
  while(cin >> M >> N){
    if(M == 0 && N == 0) break;
    for(int i=0;i<N;i++){
      cin >> D[i];
    }
    wmin = 1;
    wmax = 1500000;
    while(wmin<wmax){
      wmid = (wmin + wmax)/2;
      if(store(wmid)) wmax = wmid;
      else wmin = wmid +1;
    }
    cout << wmax << endl;
  }
  return 0;
}
