/*
  AOJ 1333
  Title:Beautiful Spacing
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))

int w,n,x[50000],memo[50000];

my_ceil(int x,int y)
{
  int ret=x/y;
  if(x % y)
    return(ret+1);
  else
    return(ret);
}

int check_last_line(int start)
{
  int i,col;
  
  for(i=start,col=0;i<n;i++)
    {
      col += x[i];
      if(col > w)
	return(0);
      col++;
    }
  return(-1);
}

int solve(int start)
{
  int col,i,words,ret,ret2;
#ifdef DEBUG
  printf("s=%d\n",start);
#endif
  col=0;

  if((ret=memo[start]))
    return(ret);
  if(check_last_line(start))  //LAST LINE => 1 SPACE
    ret2=1;
  else
    {
      ret2=w;
      col=x[start]+1;
      words=2;

      for(i=start+1;i<n;i++)
	{
	  col += x[i];
	  if(col > w)
	    break;
	  ret=1+my_ceil(w-col,words-1);
	  ret=max(solve(i+1),ret);
	  ret2=min(ret,ret2);
	  col++;
	  words++;
	}
    }
 RET:
  memo[start]=ret2;
  return(ret2);
}
main()
{
  int i,ret;


  while(scanf("%d %d",&w,&n) && (w||n))
    {
      memset(memo,0,sizeof(int)*5000);
      for(i=0;i<n;i++)
	scanf("%d",&x[i]);
      for(i=n-1;i>=0;i--)
	  ret=solve(i);

      printf("%d\n",memo[0]);
    }
  return(0);
}