#include <iostream>
using namespace std;

int main(){
	long long int book[150], n, m, s, max, tmp;
	while(cin >> m >> n){
		if(!m && !n) break;
		max = 0;
		book[0] = 0;
		for(int i = 1;i<=n;i++){
			cin >> tmp;
			book[i] = book[i-1] + tmp;
		}
		tmp = n;
		s = m - 1;
		for(int i = n;i>0, s>0;i--){
			if(book[i] > book[n] / m * s && book[i-1] < book[n] / m * s){
				if(max < book[tmp] - book[i]) max = book[tmp] - book[i];
				tmp = i;
				s--;
			}
		}
		cout << max << endl;
	}
	return 0;
}