#include <bits/stdc++.h>
using namespace std;
int k, q, maxd, c, v;
double v1, v2, maxq;
double ver;
pair<double, int> req[1000];
int ans[1000];
double dp[10000][1000];
int main() {
  cin >> k >> q;
  for (int i = 0; i < q; i++) {
    cin >> v;
    req[i].first = (double)v / 2000;
    req[i].second = i;
  }
  sort(req, req + q);
  maxq = req[q - 1].first;
  dp[1][1] = 1;
  for (int i = 2; i > 0; i++) {
    for (int x = 1; x <= min(i, k); x++) {
      v1 = (double)x / k;
      v2 = (double)(k - x + 1) / k;
      dp[i][x] = v1 * dp[i - 1][x] + v2 * dp[i - 1][x - 1];
    }
    if (i >= k)
      if (dp[i][k] > maxq) {
        maxd = i;
        break;
      }
  }
  for (int i = k; i <= maxd; i++) {
    if (c == q) break;
    while (dp[i][k] >= req[c].first) {
      ans[req[c].second] = i;
      c++;
      if (c == q) break;
    }
  }
  for (int i = 0; i < q; i++) {
    cout << ans[i] << endl;
  }
  exit(0);
}
