#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int INF = 1e9;

class C{
  public:
    int n, w, m;
    C(){}
    C(int _n, int _w, int _m){ n = _n; w = _w; m = _m; }
    bool operator > (const C &c) const {
      if(w != c.w) return w > c.w;
      return m < c.m;
    }
};

int main() {
  int M, N;
  while(cin >>M >>N && M){
    vector<int> v(N + 1); FOR(i, 1, N + 1) cin >>v[i];
    FOR(i, 1, v.size()) v[i] += v[i - 1];
    priority_queue<C, vector<C>, greater<C> > open;
    open.push(C(1, 0, 0)); 
    while(!open.empty()){
      C tmp = open.top(); open.pop();
      int n = tmp.n, w = tmp.w, m = tmp.m;
      if(n == N && m == M){ cout <<w <<endl; break; }
      if(m + 1 == M){
        int nw = v[N] - v[n - 1];
        open.push(C(N, max(w, nw), m + 1));
        continue;
      }
      FOR(next, n, N + 1){
        int nw = v[next] - v[n - 1];
        open.push(C(next + 1, max(w, nw), m + 1));
      }
    }
  }
  return 0;
}