#include <bits/stdc++.h>
using namespace std;
double dp[8001][2001];
int main() {
  int k, q;
  scanf("%d", &k);
  scanf("%d", &q);
  dp[0][k] = 1.0;
  for (int i = 1; i <= 8000; i++) {
    for (int j = 0; j < k; j++) {
      dp[i][j] = dp[i - 1][j] * (k - j) + (dp[i - 1][j + 1] * (j + 1));
      dp[i][j] /= k;
    }
  }
  while (q--) {
    int x;
    scanf("%d", &x);
    double y = x;
    for (int i = 1; i <= 8000; i++) {
      if (dp[i][0] >= (y - 1e-8) / 2000.00) {
        printf("%d\n", i);
        break;
      }
    }
  }
}
