#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#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()
const int INF = 1<<30;

template<class T> T lower_search(T lb, T ub, bool (*C)(T)) {
  while(ub-lb>1) { // ツつアツつアツづ債適ツ督鳴づ可。
    T mid = (lb+ub)/2;
    if (C(mid)) ub = mid;
    else lb = mid;
  }
  return ub;
}
int m, n;
int a[100];

bool C(int x) {
  int hoge = 0;
  REP(i,m) {
    int tmp = 0;
    while(tmp + a[hoge] <= x) {
      tmp += a[hoge];
      hoge++;
      if (hoge >= n)
        return true;
    }
  }
  return false;
}
int main() {
  while(cin >> m >> n, m+n) {
    REP(i,n) {
      cin >> a[i];
    }
    cout << lower_search(0, INF, C) << endl;
  }
}