#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<climits>
using namespace std;



int n,m;
vector<int> cost;
void init(){
  cost.clear();
}

bool input(){
  cin>>m>>n;
  if(n==0&&m==0)return 0;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    cost.push_back(tmp);
  }
  return 1;
}

int rec(int i,int x){
  int res=INT_MAX-1500010;
  if(i==n){
    return 0;
  }
  if(x==m){
    return res;
  }
  int c=cost[i];
  for(int j=i+1;j<cost.size()+1;j++){
    res=min(res,max(rec(j,x+1),c));
    c+=cost[j];
  }
  return res;
}


int solve(){
  int res=INT_MAX-1500010;
  res=min(res,rec(0,0));
  return res;
}


int main(){
  while(init(),input()){
    cout<<solve()<<endl;
  }
}