#include <iostream>
using namespace std;

int main(){
	long long int book[100], n, m, sum, width, max;
	while(cin >> m >> n){
		if(!m && !n) break;
		sum = 0;
		width = 0;
		max = 0;
		for(int i = 0;i<n;i++){
			cin >> book[i];
			sum += book[i];
		}
		for(int i = 0;i<n;i++){
			width += book[i];
			if(width >= (float)(sum / m)){
				if(max < width){
					max = width;
				}
				width = 0;
				continue;
			}
		}
		width = 0;
		for(int i = n-1;i>=0;i--){
			width += book[i];
			if(width >= (float)(sum / m)){
				if(max < width){
					max = width;
				}
				width = 0;
				continue;
			}
		}
		cout << max << endl;
	}
	return 0;
}