#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e3;
const double eps = 1e-7;
double dp[10 * MaxN + 10][MaxN + 10];
int main() {
  int n, q;
  cin >> n >> q;
  dp[1][1] = 1.0;
  for (int i = 1; i <= 10 * n; ++i) {
    for (int j = 1; j <= min(i, n); ++j) {
      dp[i + 1][j] += dp[i][j] * (double)j / (double)n;
      dp[i + 1][j + 1] += dp[i][j] * (double)(n - j) / (double)n;
    }
  }
  for (int qq = 0; qq < q; ++qq) {
    int p;
    cin >> p;
    double prob = ((double)p - eps) / 2000.0;
    for (int i = 1; i <= 10 * n; ++i) {
      if (dp[i][n] >= prob) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}
