#include <bits/stdc++.h>
using namespace std;
const int N = 10515;
double dp[N][1005];
int main() {
  int q, k;
  while (~scanf("%d %d", &k, &q)) {
    dp[0][0] = 1;
    for (int days = 1; days <= 10005; days++) {
      dp[days][0] = 0;
      for (int orbs = 1; orbs <= k; orbs++) {
        dp[days][orbs] = dp[days - 1][orbs - 1] * ((k - orbs + 1) / (k * 1.0)) +
                         dp[days - 1][orbs] * ((orbs * 1.0) / (k * 1.0));
      }
    }
    while (q--) {
      int x;
      scanf("%d", &x);
      for (int days = 1; days <= N; days++) {
        if (dp[days][k] > (double)(x / (2000.0))) {
          printf("%d\n", days);
          break;
        }
      }
    }
  }
  return 0;
}
