#include <bits/stdc++.h>
using namespace std;
inline bool equal(double _x, double _y) {
  return _x > _y - 1e-9 && _x < _y + 1e-9;
}
double dp[2][1005];
bool op;
vector<pair<double, int> > v;
int main() {
  int k, q, cnt = 1, t = 1, tmp;
  scanf("%d%d", &k, &q);
  dp[0][1] = 1;
  if (k == 1) v.push_back(make_pair(1, 1));
  while (dp[op][k] <= .5) {
    if (cnt < k) cnt++;
    for (int i = 1; i <= cnt; i++) {
      dp[!op][i] = dp[op][i - 1] * (k - i + 1) / k + dp[op][i] * i / k;
    }
    op = !op;
    t++;
    if (cnt == k) v.push_back(make_pair(dp[op][k], t));
  }
  while (q--) {
    scanf("%d", &tmp);
    printf("%d\n",
           v[lower_bound(v.begin(), v.end(), make_pair((double)tmp / 2000, 0)) -
             v.begin()]
               .second);
  }
}
