#include <iostream>
#define mx 1500000

using namespace std;
typedef long long int lli;

int m, n;
lli bk[101];

lli solve(int p, int q, lli cst)
{
  lli res = mx, t = 0;
  if(p == n) return cst;
  if(m == q){
    for(int i = p; i < n; ++i)
      t += bk[i];
    return max(t, cst);
  }
  if(n-p <= m-q){
    for(int i = p; i < n; ++i)
      t = max(t, bk[i]);
    
    return max(cst, t);
  }
  
  for(int i = p; i < n; ++i){
    t += bk[i];
    if(t > mx) break;
    res = min(res, solve(i+1, q+1, max(cst, t)));
  }

  return res;
}

int main()
{
  while(cin>>m>>n && m+n){
    for(int i = 0; i < n; ++i) cin >> bk[i];
    cout << solve(0, 1, 0) << endl;
  }

  return 0;
}