#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
double dp[10050][1005];
int ans[1005];
int main() {
  int k, q, p, i, j;
  cin >> k >> q;
  memset(dp, 0, sizeof dp);
  dp[0][0] = 1;
  for (i = 1;; ++i) {
    for (j = 1; j <= k; ++j) {
      dp[i][j] += dp[i - 1][j] * j / k;
      dp[i][j] += dp[i - 1][j - 1] * (k - j + 1.0) / k;
    }
    if (dp[i][k] >= 0.5) break;
  }
  int cout = 1;
  for (i = 1; i <= 1000; ++i) {
    while (dp[cout][k] < (i - eps) / 2000) cout++;
    ans[i] = cout;
  }
  while (q--) {
    cin >> p;
    printf("%d\n", ans[p]);
  }
  return 0;
}
