#include <bits/stdc++.h>
using namespace std;
long double p[10004][1003];
int k, q, val, ans[1003];
int main() {
  ios::sync_with_stdio(false);
  cin >> k >> q;
  p[0][0] = 1;
  int cur = 1;
  for (int i = (1); i <= (10000); i++) {
    for (int j = (1); j <= (k); j++)
      p[i][j] = p[i - 1][j] * j / k + p[i - 1][j - 1] * (k - j + 1) / k;
    while (cur < 1003 && p[i][k] * 2000 >= cur) ans[cur++] = i;
  }
  while (q--) {
    cin >> val;
    cout << ans[val] << endl;
  }
}
