#include <bits/stdc++.h>
using namespace std;
inline int gin() {
  char c = getchar();
  int s = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    s = (s << 3) + (s << 1) + (c ^ 48);
    c = getchar();
  }
  return s * f;
}
int n, q;
double f[10005][1005];
int main() {
  n = gin(), q = gin();
  f[0][0] = 1.0;
  for (int i = 1; i <= 10000; i++)
    for (int j = 1; j <= n; j++)
      f[i][j] = f[i - 1][j - 1] * (n - j + 1) / n + f[i - 1][j] * j / n;
  while (q--) {
    double p;
    scanf("%lf", &p);
    p /= 2000;
    for (int i = 1; i <= 10000; i++)
      if (f[i][n] > p) {
        printf("%d\n", i);
        break;
      }
  }
  return 0;
}
