#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 10;
double dp[10000 + 10][MAXN];
int q;
double k, p;
int main() {
  cin >> k >> q;
  dp[0][0] = 1;
  for (int i = 1; i <= 10000; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] = dp[i - 1][j] * (double)j / k +
                 dp[i - 1][j - 1] * (k - (double)j + 1) / k;
    }
  }
  while (q--) {
    cin >> p;
    int t = 1;
    while (dp[t][(int)k] < p / 2000) t++;
    cout << t << "\n";
  }
  return 0;
}
