#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 205;
double f[1005][maxn];
int ans[1005];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  f[0][0] = 1.0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < maxn; j++) {
      f[i][j] = f[i][j - 1] * i / n + f[i - 1][j - 1] * (n - i + 1) / n;
    }
  }
  for (int i = 1; i <= 1000; i++) {
    double tmp = i * 1.0 / 2000;
    int ptr = 0;
    while (f[n][ptr] < tmp) {
      ptr++;
    }
    ans[i] = ptr;
  }
  int pi;
  while (k--) {
    scanf("%d", &pi);
    printf("%d\n", ans[pi]);
  }
  return 0;
}
