#include<iostream>
#include<algorithm>
using namespace std;
int m,n,book[100];
bool ok(int x){
  int h=0,d=1;
  for(int i=0;i<n;i++){
    h += book[i];
    if(h>x){
      h = 0;
      d++;
      if(d>m) return false;
      h += book[i];
    }
  }
  return true;
}
int main(){
  while(cin>>m>>n){
    int max=1500000,min=0,s;
    if(m==0&&n==0) break;
    for(int i=0;i<n;i++) cin >> book[i];
    if(m>=n){
      sort(book,book+n,greater<int>());
      cout << book[0] << endl;
    }
    else{
      while(1){
	s = (max + min) / 2;
	if(ok(s)) max = s;
	else if(!ok(s)) min = s;
	if(min+1==max){
	  cout << max << endl;
	  break;
	}
      }
    }
  }
  return 0;
}