#include <bits/stdc++.h>
using namespace std;
const int oo = 1 << 30;
const double PI = M_PI;
const double EPS = 1e-15;
const int MAX = 1005;
int k, q;
pair<int, int> queries[MAX];
double dp[2][MAX];
int row, cnt;
int answer[MAX];
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cin >> k >> q;
  for (int i = 0; i < q; i++) {
    cin >> queries[i].first;
    queries[i].second = i;
  }
  sort(queries, queries + q);
  dp[0][0] = 1;
  row = 0;
  cnt = 0;
  for (int i = 0; i < q; i++) {
    double p = queries[i].first / 2000.;
    while (dp[row][k] < p) {
      row ^= 1;
      cnt += 1;
      for (int j = 0; j <= k; j++) dp[row][j] = 0;
      for (int j = 1; j <= k; j++)
        dp[row][j] = dp[row ^ 1][j] * j / (double)k +
                     dp[row ^ 1][j - 1] * (k - j + 1) / (double)k;
    }
    answer[queries[i].second] = cnt;
  }
  for (int i = 0; i < q; i++) cout << answer[i] << endl;
  return 0;
}
