#include <iostream>

using namespace std;

int m, n;

int books[100];

bool Check(int breadth){
  int stage = 0;
  int remaining = breadth;
  for(int i=0; i<n; i++){
	if(remaining - books[i] < 0){
	  stage++;
	  remaining = breadth;
	  if(stage >= m){
		return false;
	  }
	}
	remaining -= books[i];
  }
  return true;
}

void Solve(int max_book){
  int ng = max_book;
  int ok = 1500000;
  while(ok - ng > 1){
	int mid = (ng + ok)/2;
	if(Check(mid)){
	  ok = mid;
	}else{
	  ng = mid;
	}
  }
  cout << ok << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(1){
	cin >> m >> n;
	if(m == 0){
	  return 0;
	}
	int max_book = -1;
	for(int i=0; i<n; i++){
	  cin >> books[i];
	  if(books[i] > max_book){
		max_book = books[i];
	  }
	}
	Solve(max_book);
  }
  
  
  return 0;
}