#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int n,m;
int w[100];

bool test(int wm){
  int d = 0;
  int s = 0;
  REP(i,n){
    if(s + w[i] > wm){
      s = 0;
      d++;
    }
    s += w[i];
  }
  return d < m;
}

int main(){
  while(scanf("%d%d",&m,&n), n+m){
    int low  = 0;
    int high = 0;
    int ltmp;
    REP(i,n){
      scanf("%d",&w[i]);
      low = max(low, w[i]);
      high += w[i];
    }
    ltmp = low;
    while(low < high){
      int mid = (low + high)/2;
      bool tmp = test(mid);
      if(tmp){
	high = mid - 1;
      }else{
	low  = mid + 1;
      }
    }
    for(int i = max(ltmp,low-2);; i++){
      if(test(i)){
	printf("%d\n",i);
	break;
      }
    }
  }
  return 0;
}