#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 5;
const double eps = 1e-6;
double E[10 * N][N];
int K, Q;
int main() {
  cin >> K >> Q;
  for (int i = 0; i <= 10 * K; i++) E[i][0] = 1;
  for (int i = 1; i <= 10 * K; i++) {
    for (int j = 1; j <= K; j++) {
      E[i][j] = E[i - 1][j - 1] * j / K + E[i - 1][j] * (K - j) / K;
    }
  }
  int t;
  while (Q--) {
    cin >> t;
    int l = 0, r = 10 * K, mid;
    while (l + 1 < r) {
      mid = l + r >> 1;
      if (E[mid][K] >= 1.0 * t / 2000)
        r = mid;
      else
        l = mid;
    }
    cout << r << endl;
  }
}
