#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
double d[10010][1010];
int main() {
  int k, now = 0, q;
  double p;
  cin >> k >> q;
  for (int i = 1; i <= 10000; i++) {
    for (int j = 0; j <= k; j++) d[i][j] = 0;
    if (i == 1) {
      d[i][1] = 1.0;
    } else {
      for (int j = 1; j <= k; j++) {
        d[i][j] = d[i - 1][j] * (1.0 * j / k) +
                  d[i - 1][j - 1] * (1.0 * (k - j + 1) / k);
      }
    }
  }
  for (int i = 1; i <= q; i++) {
    cin >> p;
    for (int j = 1; j <= 10000; j++) {
      if (p - d[j][k] * 2000 <= eps) {
        cout << j << endl;
        break;
      }
    }
  }
  return 0;
}
