#include <bits/stdc++.h>
using namespace std;
const int maxN = 1005, MOD = 1e7 + 7, eps = 1e-7;
double dp[maxN];
int ans[maxN];
int k, q, d;
void prob() {
  for (int x = k; x > 0; --x) {
    dp[x] = (x * dp[x] + (k - x + 1) * dp[x - 1]) / k;
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  d = 1;
  cin >> k >> q;
  dp[0] = 1;
  for (int n = 1; d <= 1000; ++n) {
    prob();
    while (d <= 1000 && 2000 * dp[k] >= (d - eps)) {
      ans[d] = n;
      d++;
    }
    dp[0] = 0;
  }
  while (q--) {
    int x;
    cin >> x;
    cout << ans[x] << "\n";
  }
}
