#include <bits/stdc++.h>
int ans[1010];
void solve(int m, int N) {
  double dp[1010] = {1.0};
  int n = 1;
  for (int i = 1;; i++) {
    for (int j = N; j; j--) {
      dp[j] = dp[j - 1] * (N - j + 1) / N + dp[j] * j / N;
    }
    while (dp[N] * 2000.0 + 1e-7 > n) ans[n] = i, n++;
    if (n > m) break;
    dp[0] = 0;
  }
}
int main() {
  int N, T, qry[1001], m = -1;
  scanf("%d%d", &N, &T);
  for (int i = 0; i < T; i++) {
    scanf("%d", qry + i);
    if (m < qry[i]) m = qry[i];
  }
  solve(m, N);
  for (int i = 0; i < T; i++) printf("%d\n", ans[qry[i]]);
  return 0;
}
