// 2011/02/20 Tazoe

#include <iostream>
using namespace std;

bool DFS(int m, int n, int thi[100], int i, int lim, int& max)
{
	if(i==n)
		return true;

	if(m==0)
		return false;

	int sum = 0;
	while(i<n){
		if(sum+thi[i]>=lim)
			break;
		sum += thi[i];
		i++;
	}
	if(max<sum)
		max = sum;

	return(DFS(m-1, n, thi, i, lim, max));
}

int main()
{
	while(true){
		int m, n;
		cin >> m >> n;
		if(m==0&&n==0)
			break;

		int thi[101];
		for(int i=0; i<n; i++)
			cin >> thi[i];
		thi[n] = 1;

		int sum = 0;
		int max = 0;
		for(int i=0; i<n; i++){
			sum += thi[i];
			max = sum;
			if(DFS(m-1, n, thi, i+1, sum+thi[i+1], max))
				break;
		}

		cout << max << endl;
	}

	return 0;
}