#include <bits/stdc++.h>
using namespace std;
double majk;
double dp[8005][1005];
int visdp[8005][1005];
double solve(int n, int k) {
  if (n == 0 && k == 0) return 1;
  if (n == 0) return 0;
  double sol = 0;
  if (visdp[n][k]) return dp[n][k];
  if (k) {
    sol += solve(n - 1, k - 1) * ((double)k / majk);
  }
  sol += solve(n - 1, k) * ((double)(majk - k) / majk);
  visdp[n][k] = 1;
  return dp[n][k] = sol;
}
int main() {
  int k, q;
  cin >> k >> q;
  majk = k;
  solve(8000, k);
  while (q--) {
    double x;
    double e = 1e-7;
    cin >> x;
    double lhs = (x - e) / 2000.0;
    for (int i = k; i <= 8000; i++) {
      if (solve(i, k) > lhs) {
        cout << i << "\n";
        break;
      }
    }
  }
}
