#include <bits/stdc++.h>
using namespace std;
double matrix[10050][1005];
int arr[1005];
int main(int argc, const char* argv[]) {
  int k, q;
  cin >> k >> q;
  matrix[0][0] = 1;
  for (int i = 1;; i++) {
    matrix[i][0] = 0;
    for (int j = 1; j <= k; j++) {
      matrix[i][j] =
          matrix[i - 1][j - 1] * ((k - j + 1.0) / k) + matrix[i - 1][j] * j / k;
    }
    if (matrix[i][k] * 2 >= 1) {
      break;
    }
  }
  int temp = 0;
  for (int i = 1; i <= 1000; i++) {
    while (matrix[temp][k] * 2000 < i) {
      temp++;
    }
    arr[i] = temp;
  }
  while (q--) {
    int p;
    cin >> p;
    cout << arr[p] << endl;
  }
  return 0;
}
