#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const double EPS = (1e-7) / 2000;
double tmp[2][N];
int ret[N];
void solve() {
  int k, q;
  scanf("%d%d", &k, &q);
  vector<pair<int, int> > query;
  for (int i = 0; i < q; ++i) {
    int x;
    scanf("%d", &x);
    query.push_back(make_pair(x, i));
    if (k == 1) {
      printf("1\n");
    }
  }
  if (k == 1) {
    return;
  }
  sort(query.begin(), query.end());
  int pos = 0;
  for (int i = 0; i < N; ++i) {
    tmp[0][i] = tmp[1][i] = 0;
  }
  tmp[pos][1] = 1;
  int ind = 0;
  for (int day = 2; ind < query.size(); ++day) {
    int npos = pos ^ 1;
    for (int j = 1; j <= k; ++j) {
      tmp[npos][j] = 0;
      tmp[npos][j] += ((1.0 * j) / k) * tmp[pos][j];
      tmp[npos][j] += ((1.0 * (k - j + 1)) / k) * tmp[pos][j - 1];
    }
    while (ind < query.size()) {
      double cur = (double)query[ind].first / 2000 - EPS;
      int id = query[ind].second;
      if (cur <= tmp[npos][k]) {
        ret[id] = day;
        ++ind;
      } else {
        break;
      }
    }
    pos = npos;
  }
  for (int i = 0; i < q; ++i) {
    printf("%d\n", ret[i]);
  }
}
int main() { solve(); }
