#include <bits/stdc++.h>
using namespace std;
int n, k, q, p;
int ans[1005];
double dp[10 * 1005][1005];
int main(void) {
  scanf("%d%d", &n, &q);
  dp[0][0] = 1;
  for (int i = 1; i < 10 * 1005; ++i) {
    dp[i][0] = 0;
    for (int j = 1; j <= n; ++j)
      dp[i][j] = (dp[i - 1][j - 1] * (n - j + 1) + dp[i - 1][j] * j) / n;
  }
  for (int i = 1; i <= 1000; ++i) {
    while (dp[k][n] * 2000 < i) k++;
    ans[i] = k;
  }
  while (q--) {
    scanf("%d", &p);
    printf("%d\n", ans[p]);
  }
}
