#include <bits/stdc++.h>
using namespace std;
double dp[1001], dt[1001];
int an[1001];
int main() {
  int k, q;
  scanf("%d%d", &k, &q);
  dp[0] = 1.0;
  int j = 1, d = 0;
  while (j <= 1000) {
    ++d;
    for (int i = 1; i < (int)(k + 1); ++i)
      dt[i] = dp[i - 1] * ((k - i + 1) / (double)k) + dp[i] * (i / (double)k);
    for (int i = 0; i < (int)(k + 1); ++i) dp[i] = dt[i];
    while (j <= 1000 && dp[k] * 2000.0 - j > 1e-7) an[j++] = d;
  }
  for (int i = 0; i < (int)(q); ++i) {
    int t;
    scanf("%d", &t);
    printf("%d\n", an[t]);
  }
}
