#include <iostream>
using namespace std;

const int WMAX = 1500000;
const int NMAX = 100;

int n, m, a[NMAX];

bool check(int w) {
  int p, q, r;
  p = q = r = 0;
  while (p < m) {
    if (q + a[r] > w) {
      ++p;
      q = a[r];
    } else {
      q += a[r];
    }
    ++r;
    if (r >= n) {
      break;
    }
  }
  return (p<m);
}

int main() {
  int l, r, c, minw;
  bool b;
  while (1) {
    cin >> m >> n;
    if (!m && !n) break;
    minw = 0;
    for (int i=0; i<n; i++) {
      cin >> a[i];
      if (minw < a[i]) {
        minw = a[i];
      }
    }
    l = minw;
    r = WMAX;
    c = (l+r)/2;
    while (l != r) {
      b = check(c);
      if (b) {
        r = c;
      } else {
        l = c+1;
      }
      c = (l+r)/2;
    }
    cout << l << endl;
  }
  return 0;
}