#include<iostream>
using namespace std;
int n, m;
int a[101];
bool search(int v);
int main()
{	
	cin >> m >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	int l, r;
	l = 0; r = 1 << 24;
	for (int i = 0; i < 100; i++){
		int mi = (l + r) / 2;
		if (search(mi))r = mi;
		else l = mi;
	}
	cout << r << endl;
}
bool search(int v){
	int n2=0, m2=0,b=0;
	while (n2 < n&&m2 < m){
		if (b + a[n2] <= v){
			b += a[n2];
			n2++;
		}
		else{
			b = 0;
			m2++;
		}
	}
	if (n2 == n&&m2 < m)return true;
	return false;
}