/*
AizuOnline A1333
Title Beautiful Spacing
*/
#include <stdio.h>
#include <string.h>
#define min(x,y) (((x)<(y))?(x):(y))
#define max(x,y) (((x)>(y))?(x):(y))
//Global data section
int W,N;
int x[50000];
int space[50000];
//
int my_ceil(int a,int b)
{
        int ret;

        ret=a/b+((a%b)?1:0);
        return(ret);
}
int solve(int start,int depth,int caller)
{
        int sum,cnt,i;
        int ret=0,ret1,xx;
        int gyoutou=1;
        int min_sp,max_sp;
        char * color;
        if((ret=space[start])>0)
        {
                goto FIN;
        }
        cnt=0;sum=0;max_sp=0,min_sp=W;
        for(i=start;i<N;i++)
        {
                cnt++;
                
                sum += x[i];

                if(sum + (cnt-1)>W)
                        break;

                if(cnt==1)
                        ret=W-sum;
                else
                        ret=my_ceil(W-sum,cnt-1);
                ret1=solve(i+1,1+depth,start);
                max_sp=max(ret,ret1);
                min_sp=min(min_sp,max_sp);
        }
        ret=min_sp;
FIN:
        if(space[start]==0)
                space[start]=ret;
        return(ret);
}
void init()
{
        int i,sum;

        sum=x[N-1];
        space[N-1]=1;
        i=N-2;
        while(i>=0)
        {
                if(sum + 1 + x[i] > W)
                        return;
                sum += (1+x[i]);
                space[i]=1;
                i--;
        }
}
dump()
{
        int i;
        for(i=0;i<N;i++)
                printf("%d:",x[i]);
        printf("\n");
        for(i=0;i<N;i++)
                printf("%d:",space[i]);
        printf("\n");
}
main()
{
        int i,ret;

        while(EOF!=scanf("%d %d",&W,&N) && (W||N))
        {
                for(i=0;i<N;i++)
                        scanf("%d ",&x[i]);
                memset(&space[0],0,sizeof(int)*5000);
                init();

                ret=solve(0,0,0);

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