#include <bits/stdc++.h>
using namespace std;
int n, m;
double f[10005][1005];
int main() {
  cin >> n;
  f[0][0] = 1;
  for (int i = 1; i < 10005; i++) {
    for (int j = 1; j <= n; j++) {
      f[i][j] = f[i - 1][j] * j / n + f[i - 1][j - 1] * (n - j + 1) / n;
    }
  }
  int T;
  cin >> T;
  while (T--) {
    scanf("%d", &m);
    double p = 1.0 * m / 2000;
    for (int i = 1; i < 10005; i++) {
      if (f[i][n] > p) {
        printf("%d\n", i);
        break;
      }
    }
  }
  return 0;
}
