#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1E-6;
const int LEN = 1000 + 10;
double dp[10 * LEN][LEN];
int k, q;
double p;
int main() {
  while (cin >> k >> q) {
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for (int i = 0; i < 10 * LEN - 1; i++) {
      for (int j = 0; j <= k; j++)
        if (dp[i][j] > 0) {
          dp[i + 1][j] += dp[i][j] * j / k;
          dp[i + 1][j + 1] += dp[i][j] * (k - j) / k;
        }
    }
    for (int i = 0; i < q; i++) {
      cin >> p;
      p = p / 2000.0;
      for (int j = k; j < 10 * LEN; j++) {
        if (dp[j][k] > p) {
          cout << j << endl;
          break;
        }
      }
    }
  }
  return 0;
}
