#include <bits/stdc++.h>
const int N = (int)2e4 + 228;
const int K = (int)1e3 + 228;
const double EPS = 1e-7;
using namespace std;
int k, q;
double dp[N][K];
int main() {
  cin >> k >> q;
  dp[0][0] = 1.0;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] =
          (dp[i - 1][j] * j + dp[i - 1][j - 1] * (k - j + 1)) / (k + 0.0);
    }
  }
  for (int i = 1; i <= q; i++) {
    int p;
    scanf("%d", &p);
    for (int i = k; i < N; i++) {
      if (dp[i][k] * 2000.0 >= 0.0 + p - EPS) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}
