#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const double eps = 1e-7;
double d[10001][1001];
void solve() {
  int i, j, n, m;
  scanf("%d%d", &n, &m);
  d[0][0] = 1;
  for (i = 1; i <= 10000; i++)
    for (j = 1; j <= n; j++)
      d[i][j] = (d[i - 1][j] * j + d[i - 1][j - 1] * (n - j + 1)) / n;
  for (i = 1; i < 10; ++i) {
    for (int j = 0; j <= n; ++j) cout << d[i][j] << ' ';
    cout << endl;
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k, q;
  cin >> k >> q;
  vector<double> pro(k + 1, 0);
  vector<double> query;
  pro[0] = 1.0;
  while (true) {
    for (int i = k; i > 0; --i) {
      pro[i] = (i * 1.0 * pro[i] + (k - i + 1) * 1.0 * pro[i - 1]) / k;
    }
    pro[0] = 0.0;
    query.push_back(pro[k]);
    if (pro[k] > (1000 - eps) / 2000) break;
  }
  while (q--) {
    int p;
    cin >> p;
    cout << lower_bound(query.begin(), query.end(), (p - eps) / 2000) -
                query.begin() + 1
         << endl;
  }
}
