#include <iostream>
#include <algorithm>
#include <numeric>

#include <string.h>

#define INT_INF 2000000

int m, n;

int a[100 + 1];

int memo[20 + 1][100 + 1];

int search(int i, int j)
{
  if (memo[i][j] >= 0)
    return memo[i][j];

  if (i == 1)
    return memo[i][j] = std::accumulate(a + j, a + n, 0);

  int am = INT_INF;
  
  for (int s = 0; j < n; s += a[j], j ++)
    am = std::min(std::max(search(i - 1, j), s),
			   am);

  return memo[i][j] = am;
}

int main(int argc, char** argv)
{
  while (1) {
    std::cin >> m >> n;
    
    if (m == 0)
      break;

    for (int i = 0; i < n; i ++)
      std::cin >> a[i];

    memset(memo, -1, sizeof(memo));

    std::cout << search(m, 0) << std::endl;
  }
}