#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int a[110],n,m;
bool Cando(int lim){
  int cnt=0,cls=0;
  for(int i=0;i<n;i++){
    if(a[i]>lim)return false;
    if(cls+a[i]>lim){
      cls=a[i];
      cnt++;
    }
    else cls+=a[i];
  }
  if(cnt<m)return true;
  return false;
}
int main(){
 while(cin>>m>>n&&n+m){
   for(int i=0;i<n;i++)cin>>a[i];
   int left=0,right=100000000,mid;
   while(left<right-1){
     mid=(left+right)/2;
     if(Cando(mid)==false)left=mid;
     else right=mid;
   }
   cout<<right<<endl;
 }
  return 0;
}