#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,ans;
  while(cin>>a>>b){
    if(a==0&&b==0) break;
    int book[b],hei=0;
    for(int i=0;i<b;i++) cin >> book[i];
    if(a>=b){
      sort(book,book+b,greater<int>());
      cout << book[0] << endl;
    }
    else{
      for(int i=0;i<b;i++) hei += book[i];
      hei /= a;
      //cout << hei << endl;
      for(int i=hei;i<1500000;i++){
	int h[a],count=0;
	for(int j=0;j<a;j++) h[j] = 0;
	for(int j=0;j<b;j++){
	  if(h[count]+book[j]>i){
	    count++;
	    if(count>=a) break;
	    h[count] += book[j]; 
	  }
	  else if(j==b-1){
	    ans = i;
	    goto END;
	  }
	  else h[count] += book[j];
	}
      }
    END:
      cout << ans << endl;
    }
  }
  return 0;
}