#include<iostream>
using namespace std;
#include<iostream>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define fir first
#define sec second

const int M = 21;
const int inf = 1500000*2;
const int N = 101;
int dp[N][M];
int cost[N][N];
void pre(int n,int *in){
  rep(i,n){
    cost[i][i]=in[i];
    REP(j,i+1,n)cost[i][j]=cost[i][j-1]+in[j];
  }
}

int solve(int n,int m){
  rep(i,n+1)rep(j,m+1)dp[i][j]=inf;
  //dp[0][0]=0;
  REP(i,1,n+1){
    REP(j,1,m+1){
      rep(k,i){
	if (k==0)dp[i][j]=min(dp[i][j],cost[k][i-1]              );
	else     dp[i][j]=min(dp[i][j],max(dp[k][j-1],cost[k][i-1]));
      }
    }
  }
  return dp[n][m];
}

int main(){
  int n,m;
  int in[N];
  while(cin>>m>>n && n){
    rep(i,n)cin>>in[i];
    pre(n,in);
    cout << solve(n,m) << endl;
  }
}