#include "bits/stdc++.h"

using namespace std;

using ll = long long;

struct RangeBoolQuery
{
    using type = bool;
    static type id() { return false; }
    static type op(const type &l, const type &r) { return l || r; }
};

template <typename M>
class SegmentTree
{
    using T = typename M::type;
    int n;
    std::vector<T> node;

public:
    // v を基に初期化
    SegmentTree(const std::vector<T> &v)
    {
        // n は v.size() 以上の最小の2冪
        n = 1;
        while (n < int(v.size()))
            n *= 2;
        node.resize(2 * n, M::id());

        // i の子 -> 2*i+1, 2*i+2 , 親 -> (i-1)/2
        for (int i = 0; i < int(v.size()); i++)
            node[i + n] = v[i];
        for (int i = n - 1; i >= 0; i--)
            node[i] = M::op(node[2 * i], node[2 * i + 1]);
    }
    // Monoid::id 初期化
    SegmentTree(int _n)
    {
        // n は v.size() 以上の最小の2冪
        n = 1;
        while (n < _n)
            n *= 2;
        node.resize(2 * n, M::id());
    }
    // x 番目を val に更新
    void update(int x, T val)
    {
        x += n;
        node[x] = val;
        while (x >>= 1)
        {
            node[x] = M::op(node[2 * x], node[2 * x + 1]);
        }
    }
    // v[x] を M::op(v[x], val) に更新
    void operation(int x, T val)
    {
        x += n;
        node[x] = M::op(node[x], val);
        while (x >>= 1)
        {
            node[x] = M::op(node[2 * x], node[2 * x + 1]);
        }
    }
    // [a, b) の op
    T query(int l, int r)
    {
        l += n;
        r += n;
        T retl = M::id(), retr = M::id();
        while (l < r)
        {
            if (l & 1)
                retl = M::op(retl, node[l++]);
            if (r & 1)
                retr = M::op(node[--r], retr);
            l >>= 1;
            r >>= 1;
        }
        return M::op(retl, retr);
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll w, n;
    while (cin >> w >> n, w || n)
    {
        vector<ll> x(n + 1, 0), sum(n + 1, 0);
        for (int i = 1; i <= n; i++)
        {
            cin >> x[i];
            sum[i] = sum[i - 1] + x[i];
        }
        ll lb = 1e5, ub = 0;
        while (lb - ub > 1)
        {
            ll m = (lb + ub) / 2;
            // dp[i] := i を行の最後に置けるか
            SegmentTree<RangeBoolQuery> dp(n + 1);
            dp.update(0, true);
            // x[l]...x[i] を1行に置ける
            // x[r]...x[i] をm個以下のスペースで置ける
            ll l = 1, r = 1;
            for (ll i = 1; i <= n; i++)
            {
                if (sum[i] + m * (i - 1) < w)
                    continue;
                while (l < i)
                {
                    if (sum[i] - sum[l - 1] + (i - l) <= w)
                        break;
                    l++;
                }
                while (r < i)
                {
                    if (r == i - 1)
                        break;
                    if (sum[i] - sum[r] + m * (i - r - 1) < w)
                        break;
                    r++;
                }
                if (l > r || i <= l)
                    continue;
                auto ret = dp.query(l - 1, r);
                dp.update(i, ret);
            }
            bool f = false;
            for (int i = 0; i < n; i++)
            {
                if (!dp.query(i, i + 1))
                    continue;
                if (sum[n] - sum[i] + (n - i - 1) <= w)
                    f = true;
            }
            if (f)
                lb = m;
            else
                ub = m;
        }
        cout << lb << endl;
    }
}



Measured memory_bytes: 3796