#include<cstdio>
#include<algorithm>
#include<numeric>
using namespace std;

int m,n,a[110],lim;

int check(int b){
  int cnt = 1, rem = b;
  for(int i=0;i<n;i++){
    if(rem<a[i]){
      cnt++; rem = b - a[i];
    }else rem -= a[i];
  }
  return cnt;
}

int main(){
  while(scanf("%d%d",&m,&n),m){
    for(int i=0;i<n;i++)scanf("%d",a+i);
    
    int l = *max_element(a,a+n)-1, r = accumulate(a,a+n,0);
    while(r-l>1){
      int mid = (l+r)/2;
      if(check(mid)<=m)r = mid;
      else l = mid;
    }
    printf("%d\n",r);
  }
}