#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const long double eps = 1e-7;
long double f[2][N], p[N];
int ans[N], id[N];
int main() {
  int k, q;
  scanf("%d%d", &k, &q);
  for (int i = 1; i <= q; ++i) {
    int P;
    scanf("%d", &P);
    p[i] = P;
    id[i] = i;
  }
  sort(id + 1, id + 1 + q, [&](int i, int j) { return p[i] < p[j]; });
  int cur = 0, l = 1, cnt = 0;
  f[0][0] = 1.;
  while (l <= q) {
    cur ^= 1;
    for (int i = 0; i <= k; ++i) f[cur][i] = 0;
    for (int i = 0; i <= k; ++i) {
      f[cur][i] += 1. * i / k * f[cur ^ 1][i];
      f[cur][i + 1] += 1. * (k - i) / k * f[cur ^ 1][i];
    }
    cnt++;
    while (l <= q && f[cur][k] * 2000 >= p[id[l]] - eps) {
      ans[id[l]] = cnt;
      l++;
    }
  }
  for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
}
