//2分探索したよ!!
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int n, m, book[100];
bool basic(double x){
  int index = 0, dan = 0, c = 0;
  while(index < n && dan < m){
    if(c + book[index] <= x) c += book[index++];
    else c = 0, dan++;
  }
  return index == n && dan < m;
}
int main(){
  while(cin >> m >> n , m){
    for(int i = 0 ; i < n ; i++ ) cin >> book[i];
    int light = 0, left = INF;
    for(int i=0 ; i < 100 ; i++){
      int java = (light + left ) / 2;
      basic(java) ? left = java : light = java;
    }
    cout << max(light,left) << endl;
  }
}