#include <iostream>
using namespace std;
int main()
{
    int k, n, a[1001] = { 0 };
    cin >> k >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        int now, ans = 0, k1 = k, hou = 0;
        for (int j = 1;; j++) {
            int u=0;
            if (j - 1 >= a[i]) {
                hou += j - 2;
            }
            if (j > a[i]) {
                u = hou;
            }
            if (k1 - u - j <= 0) {
                break;
            }
            ans += 1;
            k1 = k1 - j;
        }
        //cout << ans << " " << k1 << " " << hou << " ";
        //now=(ans+1)/2*a[i];
        for (int j = ans; j >= a[i]; j--) {
            int u = (k1 - hou) / j;
            ans += u;
            hou = hou - j + 1;
            k1 = k1 - u * j;
        }
        cout << ans << endl;
    }
}