#include<cstdio>

using namespace std;

int simulate(int row,int turn,int weight);

int book[101];

int main(void)
{
   int row,turn;
   while(scanf("%d%d",&row,&turn),row+turn)
   {
      for(int i = 0;i < turn;i++)
         scanf("%d",&book[i]);

      int flag = 0;
      int left = 0,right = 1500000;
      while(left <= right)
      {
         int mid = (left+right)/2;
         int check = simulate(row,turn,mid);

         if(check == -1) left = mid + 1;
         else right = mid - 1;
      }
      printf("%d\n",left);
   }
   return 0;
}

int simulate(int row,int turn,int weight)
{
   int book_id = 0;
   int current_row = 1;
   int remaining_weight = weight;
   while(row >= current_row)
   {
      if(book_id == turn) return 1;
      if(book[book_id] <= remaining_weight)
      {
         remaining_weight -= book[book_id];
         book_id++;
      }
      else
      {
         current_row++;
         remaining_weight = weight;
      }
   }
   return -1;
}