#include <bits/stdc++.h>
using namespace std;
int k, q, p;
double f[1010];
int g[1010];
int main() {
  scanf("%d%d", &k, &q);
  f[1] = 1;
  int now = 1, day = 2;
  while (now <= 1000) {
    for (int j = k; j >= 1; j--)
      f[j] = f[j - 1] * (k - j + 1) / k + f[j] * j / k;
    while (now <= 1000 && f[k] > now * 1.0 / 2000) g[now++] = day;
    day++;
  }
  while (q--) {
    scanf("%d", &p);
    printf("%d\n", k == 1 ? 1 : g[p]);
  }
  return 0;
}
