#include <iostream>
#include <algorithm>
#include <climits>

int m, n;
int w[100];

const int MAX_WIDTH = 1500000;

int dfs(int i, int j){
    if(i >= m){
        return (j<n) ? -1 : 0;
    }
    if(j >= n){
        return 0;
    }

    int ans = INT_MAX;

    int width = 0;
    int res;
    for(int k=j; k<n; ++k){
        width += w[k];

        res = dfs(i+1, k+1);
        if(res >= 0){
            ans = std::min(ans, std::max(width,res));
        }
    }
    return ans;
}

int main(void){
    while(std::cin >> m >> n){
        if(m == 0 && n == 0) break;
        for(int i=0; i<n; ++i){
            std::cin >> w[i];
        }

        std::cout << dfs(0,0) << std::endl;
    }
}