#include <bits/stdc++.h>
double d[10 * 1000 + 1][1000 + 1];
int main() {
  int n, q;
  fscanf(stdin, "%d%d", &n, &q);
  d[0][0] = 1;
  for (int i = 1; i <= 10 * n; i++)
    for (int j = 1; (j <= n) && (j <= i); j++)
      d[i][j] = ((n - j + 1) * d[i - 1][j - 1] + j * d[i - 1][j]) / n;
  for (int i = 1; i <= q; i++) {
    int x;
    fscanf(stdin, "%d", &x);
    int rez = 0;
    for (int pas = 1 << 13; pas; pas >>= 1)
      if ((rez + pas <= 10 * n) && (d[rez + pas][n] * 2000 + 0.0000001 < x))
        rez += pas;
    rez++;
    fprintf(stdout, "%d\n", rez);
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
