// 2011/10/19 Tazoe

#include <iostream>
using namespace std;

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

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

		int S[101];
		S[0] = 0;
		for(int i=1; i<=n; i++)
			S[i] = S[i-1]+B[i];

		int DP[101][21];

		for(int i=1; i<=n; i++)
			DP[i][1] = S[i];

		for(int j=1; j<=m; j++)
			DP[1][j] = B[1];

		for(int i=2; i<=n; i++){
			for(int j=2; j<=m; j++){
				if(B[i]>=DP[i-1][j-1]){
					DP[i][j] = B[i];
					continue;
				}
				DP[i][j] = DP[i-1][j-1];


				for(int k=i-2; k>=1; k--){
					if(S[i]-S[k]>=DP[k][j-1]){
						if(DP[i][j]>S[i]-S[k])
							DP[i][j] = S[i]-S[k];
						break;
					}
					if(DP[i][j]>DP[k][j-1])
						DP[i][j] = DP[k][j-1];
				}
			}
		}

		cout << DP[n][m] << endl;
	}

	return 0;
}