#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  long long i, j, n, m, q, k;
  cin >> k >> q;
  double dp[10000 + 1][k + 1];
  double kk = double(k);
  memset(dp, 0, sizeof(dp));
  dp[0][0] = double(1);
  for (i = 1; i <= 10000; i++) {
    for (j = 1; j <= k; j++) {
      dp[i][j] =
          (dp[i - 1][j - 1] * (double((kk - double(j) + double(1)) / kk)) +
           dp[i - 1][j] * (double((double(j)) / kk)));
    }
  }
  while (q--) {
    double p;
    cin >> p;
    p = p / double(2000);
    long long start = 1;
    long long end = 10000;
    long long ans = 1;
    while (start <= end) {
      long long mid = (start + end) / 2;
      if (dp[mid][k] >= p) {
        ans = mid;
        end = mid - 1;
      } else
        start = mid + 1;
    }
    cout << ans << endl;
  }
  return 0;
}
