#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
double dp[N][1010];
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i <= n * 10; i++) {
    for (int j = 0; j <= min(i, n); j++) {
      dp[i + 1][j + 1] += dp[i][j] * (1.0 * (n - j) / n);
      dp[i + 1][j] += dp[i][j] * (1.0 * j / n);
    }
  }
  for (int i = 0; i < q; i++) {
    double p;
    scanf("%lf", &p);
    for (int j = n;; j++) {
      if (dp[j][n] < p / 2000) continue;
      printf("%d\n", j);
      break;
    }
  }
  return 0;
}
