#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int M, N;
int t[128];
int dp[32][128];

int dfs(int m, int n){
  //  printf("%d %d\n", m, n);
  if(m == M && n == N) return 0;
  if(m == M) return INF;
  if(n == N) return 0;
  if(dp[m][n] >= 0) return dp[m][n];

  int res = INF;
  for(int i = n+1; i < N+1; i++){
    res = min(res, max(dfs(m+1, i), t[i] - t[n]));
  }

  return dp[m][n] = res;
}

int main(){
  while(scanf("%d%d", &M, &N) && M + N){
    memset(dp, -1, sizeof(dp));
    t[0] = 0;
    rep(i, N) scanf("%d", t+i+1);
    rep(i, N) t[i+1] += t[i];

    printf("%d\n", dfs(0, 0));
  }
}