#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

int hon[100];
int m,n;

bool can(int w){
  int dan=1,tw=0;
  rep(i,n){
    if(hon[i]>w)return false;
    if(tw+hon[i]<=w)tw+=hon[i];
    else{
      tw=hon[i];
      ++dan;
    }
    //cout<<dan<<" "<<tw<<endl;
    if(dan>m)return false;
  }
  return true;
}

main(){
  while(cin>>m>>n,m){
    rep(i,n)cin>>hon[i];

    int l=0,r=1500000;

    while(l<r){
      int mid=(l+r)/2;
      //cout<<mid<<endl;
      if(can(mid))r=mid;
      else l=mid+1;
    }
    cout<<l<<endl;
  }
}