#include<bits/stdc++.h>
using namespace std;

int m, n;
int data[101];

bool func( int num ) {
  int sum = 0, cnt = 1;
  for(int i=0; i<n; i++) {
    if( sum + data[i] <= num ) {
      sum += data[i];
    } else {
      sum = data[i];
      cnt++;
    }
  }

  if( cnt <= m ) return true;
  else return false;
}


int main() 
{
  while( cin >> m >> n, m+n ) {
    int ma = 0;
    for(int i=0; i<n; i++) {
      cin >> data[i];
      ma = max(ma, data[i]);
    }
    
    int l = 0, r = 1500000;
    int now;
    while( l != r ) {
      now = (l + r) / 2;
      if( now >= ma && func( now ) ) {
	r = now;
      } else {
	l = now+1;
      }
    }
    
    cout << l << endl;
  }
  
}