#include <bits/stdc++.h>
using namespace std;
bool exitInput = false;
int ntest = 1, itest = 1;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const char *directions[4] = {"NE", "SE", "Sw", "Nw"};
const long long Mod = 1000000007LL;
const int maxn = 2000 + 5;
const int maxv = 5000 + 5;
const int maxe = 1000011 + 5;
struct Query {
  int idx, p;
  Query() {}
  bool operator<(const Query &other) const {
    if (p != other.p) return p < other.p;
    return idx < other.idx;
  }
};
Query q[1111];
int K, nq, ans[1111];
double f[1111], g[1111];
int main() {
  int i, j, k;
  for (itest = 1; itest <= ntest; ++itest) {
    scanf("%d %d", &K, &nq);
    for (i = 0; i < nq; ++i) {
      scanf("%d", &k);
      q[i].idx = i;
      q[i].p = k;
    }
    sort(q, q + nq);
    int id = 0;
    g[0] = 1.0;
    for (int d = 1; id < nq; ++d) {
      for (i = 1; i <= K && i <= d; ++i) {
        f[i] = (g[i] + g[i - 1]) * 1.0 * i / K;
      }
      for (i = 0; i <= K && i <= d; ++i) {
        g[i] = f[i];
      }
      while (id < nq && f[K] * 2000 + 1e-7 >= q[id].p) {
        ans[q[id].idx] = d;
        ++id;
      }
    }
    for (i = 0; i < nq; ++i) printf("%d\n", ans[i]);
  }
  return 0;
}
