#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-7;
const int N = 1005;
const int D = 10000;
double dp[D][N];
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  dp[0][0] = 1;
  for (int d = 0; d + 1 < D; d++)
    for (int has = 0; has <= n; has++) {
      double p = dp[d][has];
      double pn = 1.0 * (n - has) / n;
      dp[d + 1][has] += p * (1 - pn);
      dp[d + 1][has + 1] += p * pn;
    }
  (void)0;
  for (int i = 0; i < m; i++) {
    int pi;
    scanf("%d", &pi);
    for (int ans = 0;; ans++) {
      double f = dp[ans][n];
      if (f >= (pi - EPS) / 2000) {
        printf("%d\n", ans);
        break;
      }
    }
  }
}
int main() {
  solve();
  (void)0;
  return 0;
}
