// test1.cpp : Defines the entry point for the console application.
//
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <queue>
using namespace std;
queue<int> select, width;

int main(void)
{
	int value[1000], suffix = 0;

	while (1) {
		int stage, nbook, book[100];

		scanf("%d %d", &stage, &nbook);
		if (stage == 0 && nbook == 0) {
			break;
		}
		for (int i = 0; i < nbook; i++) {
			scanf("%d", &book[i]);
		}

		int sum = 0;
		for (int i = 1; i <= nbook; i++) {
			select.push(i);
			sum += book[i - 1];
			width.push(sum);
		}

		int front;
		for (int i = 1; i < stage; i++) {
			int size = select.size();
			for (int j = 0; j < size; j++) {
				front = select.front();
				if (front != nbook) {
					for (int k = front + 1; k <= nbook; k++) {
						sum = 0;
						for (int l = front; l < k; l++) {
							sum += book[l];
						}

						if (width.front() < sum) {
							if (i + 1 == stage) {
								if (k == nbook) {
									width.push(sum);
									select.push(k);
								}
							}
							else {
								width.push(sum);
								select.push(k);
							}
						}
						else {
							if (i + 1 == stage) {
								if (k == nbook) {
									width.push(width.front());
									select.push(k);
								}
							}
							else {
								width.push(width.front());
								select.push(k);
							}
						}
					}
				}
				else {
					width.push(width.front());
					select.push(nbook);
				}
				select.pop();
				width.pop();
			}
		}

		int size = width.size(), min = 100000;
		for (int i = 0; i < size; i++) {
			if (min > width.front()) {
				min = width.front();
			}
			width.pop();
			select.pop();
		}
		value[suffix++] = min;
	}

	for (int i = 0; i < suffix; i++) {
		printf("%d\n", value[i]);
	}

	return 0;
}